Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

ACCESS_TOKEN_SCOPE_INSUFFICIENT error comes for GenerativeAI with ADC Key

Hello,

 I am using the ADC Key Method to authenticate the Google Generative AI api in Node JS. But getting the below error
Code: 

 

 

 

const ai = new GoogleGenAI({
    keyFile: process.env.GOOGLE_APPLICATION_CREDENTIALS,
    scopes: [
        'https://www.googleapis.com/auth/generative-language'
    ]
})
const response = await ai.models.generateContent({
     model: 'gemini-2.5-pro',
     contents: prompt
})

 

 

Response:

 

 

{
  "error": {
    "code": 403,
    "message": "Request had insufficient authentication scopes.",
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "ACCESS_TOKEN_SCOPE_INSUFFICIENT",
        "domain": "googleapis.com",
        "metadata": {
          "service": "generativelanguage.googleapis.com",
          "method": "google.ai.generativelanguage.v1beta.GenerativeService.GenerateContent"
        }
      }
    ]
  }
}

 

 

I have given Owner & Editor Roles to the Service Account. But still facing the issue

 

0 2 196
2 REPLIES 2