generative-ai-docs icon indicating copy to clipboard operation
generative-ai-docs copied to clipboard

Encountering a "Permission denied" error while using an API

Open stan1233 opened this issue 1 year ago • 2 comments

Description of the bug:

When encountering a "Permission denied" error while using an API, does it imply that there's an issue with my account? Could you please advise on how to resolve this problem?

curl \
  -H 'Content-Type: application/json' \
  -d '{"contents":[{"parts":[{"text":"Write a story about a magic backpack"}]}]}' \
  -X POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=AIzaSyAhTarnL1PaQn_yu_uVf0gia9wUyJx8RSI'
{
  "error": {
    "code": 403,
    "message": "Permission denied: Consumer 'api_key:AIzaSyAhTarnL1PaQn_yu_uVf0gia9wUyJx8RSI' has been suspended.",
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "CONSUMER_SUSPENDED",
        "domain": "googleapis.com",
        "metadata": {
          "service": "generativelanguage.googleapis.com",
          "consumer": "projects/578829824020"
        }
      }
    ]
  }
}

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

stan1233 avatar Apr 08 '24 11:04 stan1233

Same

P1nk-L0rD avatar Apr 13 '24 19:04 P1nk-L0rD

"message": "Permission denied: Consumer 'api_key:AIzaSyAhTarnL1PaQn_yu_uVf0gia9wUyJx8RSI' has been suspended.", I have 2 comments for you.

  1. Please never post your keys in any online forums, try not to commit them to github either (API keys, API passwords, secret keys etc)
  2. Please read the output, it says your API key has been suspended. Please find out why and how at the docs, customer support or even the stauts of your key at the platform where you generated (Google or Kaggle I suppose) Happy Coding!

Namanm1994 avatar May 29 '24 09:05 Namanm1994