Google search in SerpApi 問題(授權失敗)

我一直在「Google search in SerpApi」節點中遇到未授權錯誤,我已經正確地在那裡應用了 API 金鑰

問題
無法使用這些設定連接

授權失敗 - 請檢查您的認證

{

“name”: “Telgram1 Sub Workflow Search”,

“nodes”: [

{

  "parameters": {

    "inputSource": "passthrough"

  },

  "type": "n8n-nodes-base.executeWorkflowTrigger",

  "typeVersion": 1.1,

  "position": [

    0,

    0

  ],

  "id": "f5f9534c-c16c-4713-bbe7-ce63f8205078",

  "name": "When Executed by Another Workflow"

},

{

  "parameters": {

    "promptType": "define",

    "text": "={{ $json.query }}",

    "options": {

      "systemMessage": "=You are a helpful assistant for research\\n\\nyou can use your tools to search the web."

    }

  },

  "type": "@n8n/n8n-nodes-langchain.agent",

  "typeVersion": 3.1,

  "position": [

    208,

    0

  ],

  "id": "41e9252f-13b1-4c17-b449-8e76ee824652",

  "name": "AI Agent"

},

{

  "parameters": {

    "model": {

      "__rl": true,

      "mode": "list",

      "value": "gpt-5-mini"

    },

    "builtInTools": {},

    "options": {}

  },

  "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",

  "typeVersion": 1.3,

  "position": [

    80,

    208

  ],

  "id": "8adc58e1-a04e-4849-94c2-9177b54e1e8b",

  "name": "OpenAI Chat Model",

  "credentials": {

    "openAiApi": {

      "id": null,

      "name": "",

      "__aiGatewayManaged": true

    }

  }

},

{

  "parameters": {},

  "type": "@n8n/n8n-nodes-langchain.toolWikipedia",

  "typeVersion": 1,

  "position": [

    224,

    304

  ],

  "id": "499b12b9-5f77-4f53-acd9-692237079398",

  "name": "Wikipedia"

},

{

  "parameters": {

    "resource": "all",

    "limit": 20,

    "additionalFields": {

      "keyword": "={{ /\*n8n-auto-generated-fromAI-override\*/ $fromAI('Keyword', \`\`, 'string') }}"

    }

  },

  "type": "n8n-nodes-base.hackerNewsTool",

  "typeVersion": 1,

  "position": [

    368,

    288

  ],

  "id": "da7806e6-7a74-48b4-9733-d1cb0aa634ea",

  "name": "Hacker News"

},

{

  "parameters": {

    "q": "={{ /\*n8n-auto-generated-fromAI-override\*/ $fromAI('Search_Query__q\_', \`\`, 'string') }}",

    "location": "={{ /\*n8n-auto-generated-fromAI-override\*/ $fromAI('Location__location\_', \`\`, 'string') }}",

    "additionalFields": {},

    "requestOptions": {}

  },

  "type": "n8n-nodes-serpapi.serpApiTool",

  "typeVersion": 1,

  "position": [

    544,

    288

  ],

  "id": "67ddaf70-2408-4e19-a79c-a355703a0d35",

  "name": "Google search in SerpApi",

  "credentials": {

    "serpApi": {

      "id": "uF8n5EBM0zMke4ll",

      "name": "SerpApi account"

    }

  }

},

{

  "parameters": {

    "promptType": "define",

    "text": "={{ $json.query }}",

    "options": {

      "systemMessage": "=You are a helpful research agent.\\nYou use your Tools to search the web, you have access to hackernwes, wikipedia and the serpAPI, surch them all or use the rigth one."

    }

  },

  "type": "@n8n/n8n-nodes-langchain.agent",

  "typeVersion": 1.7,

  "position": [

    1152,

    720

  ],

  "id": "a71e2746-f386-4e99-91c4-4d3ab0b4d758",

  "name": "AI Agent1"

},

{

  "parameters": {

    "model": {

      "__rl": true,

      "value": "gpt-4o",

      "mode": "list",

      "cachedResultName": "gpt-4o"

    },

    "options": {}

  },

  "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",

  "typeVersion": 1.2,

  "position": [

    1072,

    960

  ],

  "id": "671a8ea6-707f-4409-b2d1-6a14d8dc5ffa",

  "name": "OpenAI Chat Model1"

},

{

  "parameters": {},

  "type": "@n8n/n8n-nodes-langchain.toolWikipedia",

  "typeVersion": 1,

  "position": [

    1216,

    960

  ],

  "id": "8fd5c8fb-a016-4fac-bbdd-47dbf6faa59b",

  "name": "Wikipedia1"

},

{

  "parameters": {

    "resource": "all",

    "limit": 20,

    "additionalFields": {

      "keyword": "={{ /\*n8n-auto-generated-fromAI-override\*/ $fromAI('Keyword', \`\`, 'string') }}"

    }

  },

  "type": "n8n-nodes-base.hackerNewsTool",

  "typeVersion": 1,

  "position": [

    1360,

    960

  ],

  "id": "7aa1304b-cd8c-40a8-8c10-25b60516f28f",

  "name": "Hacker News1"

}

],

“pinData”: {

"When Executed by Another Workflow": [

  {

    "json": {

      "query": "Honda bike news"

    }

  }

]

},

“connections”: {

"When Executed by Another Workflow": {

  "main": [

    [

      {

        "node": "AI Agent",

        "type": "main",

        "index": 0

      }

    ]

  ]

},

"OpenAI Chat Model": {

  "ai_languageModel": [

    [

      {

        "node": "AI Agent",

        "type": "ai_languageModel",

        "index": 0

      }

    ]

  ]

},

"Wikipedia": {

  "ai_tool": [

    [

      {

        "node": "AI Agent",

        "type": "ai_tool",

        "index": 0

      }

    ]

  ]

},

"Hacker News": {

  "ai_tool": [

    [

      {

        "node": "AI Agent",

        "type": "ai_tool",

        "index": 0

      }

    ]

  ]

},

"Google search in SerpApi": {

  "ai_tool": [

    [

      {

        "node": "AI Agent",

        "type": "ai_tool",

        "index": 0

      }

    ]

  ]

},

"OpenAI Chat Model1": {

  "ai_languageModel": [

    [

      {

        "node": "AI Agent1",

        "type": "ai_languageModel",

        "index": 0

      }

    ]

  ]

},

"Wikipedia1": {

  "ai_tool": [

    [

      {

        "node": "AI Agent1",

        "type": "ai_tool",

        "index": 0

      }

    ]

  ]

},

"Hacker News1": {

  "ai_tool": [

    [

      {

        "node": "AI Agent1",

        "type": "ai_tool",

        "index": 0

      }

    ]

  ]

}

},

“active”: false,

“settings”: {

"executionOrder": "v1",

"binaryMode": "separate"

},

“versionId”: “c1435b84-8b12-45c4-b332-09340a9fdc93”,

“meta”: {

"templateCredsSetupCompleted": true,

"instanceId": "9f81a7770771d2db166482bd80259ea45591cbec80ffb304895a93391779c88e"

},

“id”: “N2zPDbeMqBtZ5SwX”,

“tags”:

}

@Ahmed_Ali9

首先,試試「重新整理」的技巧。有時 n8n 看起來像是已連接到你的帳戶,但內部連結實際上已損壞。要修正這個問題,請打開 SerpApi 節點,將憑證設定為「無」,然後從下拉選單再次選擇你的帳戶。這通常會強制系統喚醒並識別你的 API 金鑰。

其次,仔細檢查你實際上在使用哪個服務。有兩個非常相似的服務:SerpApi 和 Serper.dev。你使用的 n8n 節點是專門為 SerpApi 建立的。如果你不小心註冊了 Serper.dev 並使用了那個金鑰,它將永遠無法在這個特定節點中運作,你將持續看到「未授權」的錯誤。

第三,尋找「看不見的」錯誤。在將 API 金鑰貼到 n8n 時,不小心複製開頭或結尾的微小空格是非常常見的。即使只有一個空格也會使金鑰無效。回到你的憑證設定,仔細檢查文字周圍是否沒有多餘空格。

第四,在 n8n 之外測試金鑰,看看問題是否出在你的帳戶。你可以在電腦的終端機中使用簡單的指令,或檢查你的 SerpApi 儀表板來做到這一點。這可以幫助你判斷金鑰是否真的已過期,或你是否已用完搜尋配額,這也會導致授權失敗。

curl "https://serpapi.com/search.json?q=n8n&api_key=YOUR_API_KEY"

最後,如果官方節點仍然無法運作,你可以使用「後門」。與其使用 SerpApi 節點,不如使用通用的「HTTP 請求」節點。這允許你手動連接到該服務。它通常更可靠,因為它繞過了 SerpApi 節點的特定設定,讓你直接控制連接。

@Ahmed_Ali9,早安!

請分享你的金鑰測試結果,可透過終端或瀏覽器。
我們首先需要驗證是否沒有問題。
確認你在 serpai 上的方案
不要使用社群節點,優先選擇 HTTPS。