N8n Cloud: Authorization Failed For Groq & Google APIs

by ADMIN 57 views
Iklan Headers

Hey everyone,

I'm encountering a frustrating issue with my n8n cloud instance (sreeram1.app.n8n.cloud). I'm building a workflow that needs to interact with external AI APIs, specifically Groq and Google Gemini, using the HTTP Request node. However, I consistently get an Authorization failed error, even though I'm absolutely sure my API keys are correct. It's driving me nuts, so I'm hoping someone here can shed some light on this.

The Problem

The core issue is that my n8n instance seems unable to successfully authenticate with any external API. I've tried two major providers, Groq and Google Gemini, and both are giving me the same Authorization failed error. This is happening despite the fact that I've verified my API keys are valid and working outside of n8n.

Debugging Steps Taken

I've gone through a pretty thorough debugging process to try and isolate the problem. Here's what I've done so far:

  1. Confirmed the Authorization failed error with both Groq and Google Gemini: This rules out the possibility of a specific issue with one API provider.
  2. Verified the Groq API key externally using cURL: I sent a test request using cURL and the same API key I'm using in n8n, and it worked perfectly. This confirms that the key itself is valid and that the Groq API is functioning correctly.
  3. Created multiple new credentials within n8n: I thought maybe there was an issue with how the credentials were being stored or accessed, so I created fresh credentials and carefully copy-pasted the API keys. Unfortunately, the error persisted.
  4. Bypassed the n8n credential manager and hardcoded the authentication header: This was my last-ditch effort to rule out any issues with the credential management system. I set the Authentication option in the HTTP Request node to None and manually added the x-goog-api-key header with my API key directly in the node's configuration. Even with this direct approach, I still got the Authorization failed error.

This last step, in particular, makes me suspect that the problem isn't with my workflow configuration or the API keys themselves. Instead, it seems like there might be an issue with the networking environment of my n8n cloud instance. It's as if the instance is unable to make successfully authenticated requests to external APIs.

Error Message

The error message I'm receiving from the HTTP Request node is:

Authorization failed - please check your credentials

Which, as you can see, isn't super helpful in this case, since I've checked and double-checked my credentials.

Workflow Structure

To give you a better idea of what I'm working with, here's a representation of my workflow structure. It's a pretty simple setup:

{
  "nodes": [
    {
      "parameters": {},
      "id": "7d9a13a2-23f4-41d8-842c-29d984d72d2b",
      "name": "RSS Read",
      "type": "n8n-nodes-base.rssFeedRead",
      "typeVersion": 1,
      "position": [
        860,
        300
      ]
    },
    {
      "parameters": {
        "batchSize": 1
      },
      "id": "e446d790-a359-4217-90c7-20b153b679f2",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 2,
      "position": [
        1100,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent",
        "authentication": "none",
        "options": {},
        "bodyParametersJson": "={{...}}",
        "headerParameters": {
          "parameters": [
            {
              "name": "x-goog-api-key",
              "value": "my-api-key-is-pasted-here"
            }
          ]
        }
      },
      "id": "2364427b-231a-4288-9184-b52f1b40209c",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        1340,
        300
      ]
    }
  ],
  "connections": {}
}

It reads an RSS feed, loops over the items, and then sends a request to the Google Gemini API using the HTTP Request node. As you can see, I've even tried hardcoding the API key directly in the header parameters, but still no luck.

Output from the Last Node

The HTTP Request node consistently fails and returns the following error object:

{
  "message": "401 - \"Authorization failed - please check your credentials\"",
  "name": "NodeApiError",
  "stack": "NodeApiError: 401 - \"Authorization failed - please check your credentials\"\n    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js:1620:19)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:1333:23)\n    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:1030:29"
}

Debug Info

Here's some debug information about my n8n instance:

Core

- n8nVersion: 1.104.1
- platform: docker (cloud)
- nodeJsVersion: 22.17.0
- database: sqlite
- executionMode: regular
- concurrency: 5
- license: community

Storage

- success: all
- error: all
- progress: false
- manual: true
- binaryMode: filesystem

Pruning

- enabled: true
- maxAge: 168 hours
- maxCount: 2500 executions

Client

- userAgent: mozilla/5.0 (macintosh; intel mac os x 10_15_7) applewebkit/537.36 (khtml, like gecko) chrome/138.0.0.0 safari/537.36
- isTouchDevice: false

Seeking Help

So, guys, I'm really stumped here. I've tried everything I can think of, and I'm still getting this Authorization failed error. It seems like the issue might be with the networking configuration of my n8n cloud instance, but I'm not sure how to diagnose or fix that. Has anyone else experienced a similar issue? Any suggestions on what I can try next would be greatly appreciated!

Thanks in advance for your help!