描述問題/錯誤/問題
我的 X 帳戶已遷移到新的付費使用層級,並獲得了 $10 額度。一旦額度用完,它就停止發佈了。我添加了更多額度,但這也沒有解決問題。
按照建議,我在 X Dev 中創建了一個新應用程式,確保它具有寫入存取權限,並將新認證資訊提供給了 N8N 中的 X 認證。
我可以驗證應用程式,但每當我嘗試發送推文時,都會收到 403 禁止錯誤。
關於你的 n8n 設定的資訊
- n8n 版本: 2.18.7
- 資料庫(預設: SQLite): Postgres
- n8n EXECUTIONS_PROCESS 設定(預設: own, main): 預設
- 執行 n8n 的方式(Docker、npm、n8n cloud、桌面應用程式): Docker,在 Traefik 後面
- 作業系統: Ubuntu 24
@Stuart_Grimshaw 你能分享完整的 403 錯誤或 403 錯誤的截圖嗎?這樣我們可以看看是否有任何額外的詳細資訊能幫助我們診斷你的情況?
這是來自 X API 的錯誤:
`
{ “detail”: “You are not permitted to perform this action.”, “type”: “about:blank”, “title”: “Forbidden”, “status”: 403 }`
以及來自同一錯誤的完整堆疊追蹤:
NodeApiError: Forbidden - perhaps check your credentials?
at ExecuteContext.twitterApiRequest (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@aws-sdk+credential-providers@3.808.0_asn1.js@5_8da18263ca0574b0db58d4fefd8173ce/node_modules/n8n-nodes-base/nodes/Twitter/V2/GenericFunctions.ts:56:9) at processTicksAndRejections (node:internal/process/task_queues:104:5)
at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@aws-sdk+credential-providers@3.808.0_asn1.js@5_8da18263ca0574b0db58d4fefd8173ce/node_modules/n8n-nodes-base/nodes/Twitter/V2/TwitterV2.node.ts:237:22) at WorkflowExecute.executeNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@opentelemetry+api@1.9.0_@opentelemetry+exporter-trace-otlp_d301200d8c5446bebb311523c3c1b485/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1048:9) at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@opentelemetry+api@1.9.0_@opentelemetry+exporter-trace-otlp_d301200d8c5446bebb311523c3c1b485/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1239:11)
at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@opentelemetry+api@1.9.0_@opentelemetry+exporter-trace-otlp_d301200d8c5446bebb311523c3c1b485/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1687:27
at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@opentelemetry+api@1.9.0_@opentelemetry+exporter-trace-otlp_d301200d8c5446bebb311523c3c1b485/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:2339:11
歡迎來到 n8n 社群 @Stuart_Grimshaw
我會在確認 X 應用程式設定為讀取和寫入,以及目前的 X 開發者層級允許透過 API 進行發佈之後,重新建立 n8n X OAuth2 認證。由於 n8n 的 X 節點 V2 使用 OAuth2,而且 X 在 n8n 外部強制執行計畫和端點限制。
您看到的特定 403(「您無法執行此操作」)在層級遷移後幾乎總是範圍問題而非計費問題,且有一個隱匿的原因:在開發者入口網站中更改應用程式的權限不會更新已經簽發的令牌。如果 OAuth 連線是在應用程式切換到「讀寫」之前建立的,n8n 持有的存取令牌仍然只有唯讀範圍,而 X 對 POST /2/tweets 會傳回這個 403。新增點數不會改變這一點,這與您看到的情況相符。
修復的步驟順序:
- 在 X 開發者入口網站中,確認應用程式位於專案內(獨立應用程式會在 v2 端點上取得 403,無論權限為何),且使用者驗證設定顯示「讀寫」且應用程式類型為 Web App。
- 在進行任何權限變更後,點擊金鑰和令牌上的「重新產生」。這是實際使舊範圍失效的步驟。
- 在 n8n 中,不要編輯舊憑證。將其刪除,使用重新產生的用戶端 ID 和祕密建立全新的 X OAuth2 憑證,並重新執行 OAuth 流程。
- 在同意畫面上,閱讀列出的權限。如果清單中沒有「為您發佈和刪除貼文」,寫入範圍仍未被請求,步驟 1 中的設定未保存。
另一個值得了解的按使用次數付費的怪癖:讀取和寫入按每個請求分別計費,因此工作正常的讀取節點證明計費沒有問題,但對寫入授權沒有任何說明。步驟 4 中的同意畫面檢查是可靠的指標。