Skip to content

Requests to Google Gemini API failing with 403 due to missing Referer header #10

Description

@tube2sheet

I am encountering a 403 Forbidden error when using GeminiApp to make doGet requests to the Google Gemini API. The error message indicates that the Referer header is missing or empty:

Request failed with code 403 - {
  "error": {
    "code": 403,
    "message": "Requests from referer \u003cempty\u003e are blocked.",
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "API_KEY_HTTP_REFERRER_BLOCKED",
        "domain": "googleapis.com",
        "metadata": {
          "consumer": "projects/XXXXXXXXXXXX",
          "service": "generativelanguage.googleapis.com",
          "httpReferrer": "\u003cempty\u003e"
        }
      },
      {
        "@type": "type.googleapis.com/google.rpc.LocalizedMessage",
        "locale": "en-US",
        "message": "Requests from referer \u003cempty\u003e are blocked."
      }
    ]
  }
}

Relevant code might be in _getHeaders(url) {...}

I am using an API key to authenticate and have set website restrictions to the key. Is there a way to send the Referer?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions