大家好,
我在 n8n 自託管和從 JSON 匯入的工作流程方面遇到了一個普遍問題。
這不僅限於 Slack。我在多個整合中都遇到了這個問題:
- Slack
- Airtable
- Notion
- Shopify
- OpenAI
- Gemini
- OpenRouter
- Google Drive
- Gmail
- 其他類似的認證
背景:
- 認證已在 n8n 中建立。
- 認證測試連接正常。
- 它們在同一個 n8n 環境中建立。
- Token/API 金鑰可以正常使用。
- 但是當我打開從 JSON 匯入的工作流程中的節點時,認證下拉菜單顯示為空或「No credentials yet」。
- 重新載入瀏覽器無法解決此問題。
- 清除快取也無法解決此問題。
- 此問題出現在匯入的節點上,不僅限於特定的某個節點。
奇怪的是:
如果我在節點內按下「Set up credential」並從那裡建立新認證,那麼該節點就開始識別認證並正常運作。
我們目前使用的臨時解決方案是:
- 從節點本身建立一個新的/虛假的認證。
- 然後 n8n 就允許選擇認證。
- 選擇或重新建立正確的認證。
- 之後刪除臨時認證。
但這不是很實用,因為需要在許多節點和許多整合上都這樣做。
主要問題:
如何正確修復此問題?
具體問題:
- 這是 n8n 中所有權/使用者背景/專案背景的問題嗎?
- 從「認證」畫面建立的認證是否因某個原因而無法用於匯入的工作流程?
- 有沒有辦法重新指派或重新連結現有認證到匯入的工作流程,而不是逐個節點地重新建立?
- 是否存在推薦的 CLI 命令或方法來匯入工作流程並維護或重新指派認證?
- 工作流程和認證是否需要恰好屬於同一使用者/專案?
- 能否從 n8n UI、資料庫、CLI 或 API 修復此問題?
- n8n MCP / Claude Code 能否將現有認證指派給匯入的節點,還是出於安全考慮必須手動執行?
環境:
- n8n 自託管
- 從 JSON 匯入的工作流程
- 在 n8n 中建立的認證
- 認證測試正確
- 此問題影響多個應用程式,不僅限於 Slack
- 從節點本身建立認證確實有效
我需要知道如何以全局方式正確解決此問題,而不是逐個節點地解決。
謝謝。
n8n 設置的相關信息
- n8n 版本:
- 資料庫(預設:SQLite):
- n8n EXECUTIONS_PROCESS 設置(預設:own、main):
- 執行 n8n 的方式(Docker、npm、n8n cloud、桌面應用):
- 作業系統:
Welcome @miki007 to our community! I’m Jay and I am a n8n verified creator.
This is expected behavior - when you import a workflow JSON, the credential IDs inside the JSON won’t match the IDs on your instance, so nodes show empty dropdowns. The cleanest fix: after importing, use the “Credential” dropdown in each affected node - since your credentials are already created and tested, they should appear in the list, just not pre-selected. Select the right credential and save. If you’re importing many workflows, n8n CLI has an n8n import:workflow command that can help with bulk operations, though manual re-mapping is still needed for credentials unless you’re migrating between identical instances using n8n export:credentials + n8n import:credentials.
Thanks for the answer. I understand that imported workflow JSON files keep credential IDs/names from the original instance and that these IDs won’t match my instance automatically.
However, my issue is a bit different: the problem is not only that credentials are not pre-selected. In many imported nodes, the credential dropdown is completely empty or shows “No credentials yet”, even though the credentials already exist in the same n8n instance and test successfully.
If I create a new credential from inside that same node using “Set up credential”, then the node starts recognizing credentials. That makes me think it may be related to one of these:
-
the imported workflow and the existing credentials belong to different users/projects/spaces;
-
the imported node expects a different credential type than the credential I created from the Credentials screen;
-
the workflow was imported into the wrong user/project context.
So my follow-up question is:
What is the recommended way to globally fix this?
Should I import workflows with n8n import:workflow --projectId or --userId so they land in the same context as the credentials?
Is there a supported way to reassign existing credentials to imported workflows in bulk, or is manual remapping/recreating nodes required?
I’m trying to avoid creating temporary credentials node by node across many workflows.
Your diagnosis is right - option 1 is almost certainly the cause. The --projectId and --userId flags in n8n import:workflow control which project/user owns the workflow, but they don’t remap credential IDs inside the workflow JSON. There’s no built-in bulk credential reassignment. The cleanest approach for bulk imports is to export your credentials from the source instance with n8n export:credentials --all, import them to the new instance with n8n import:credentials, and then import the workflows - since the credential IDs will match, nodes won’t show empty dropdowns. If you’re starting fresh without the source credentials, the fastest workaround is still the “Set up credential” trick you already found, since it forces the node to register with a valid ID on your instance.