Skip to content

Bug: OAuth scopes missing for GoogleAuth for Vertex AI service account auth #15109

@sauravhiremath

Description

@sauravhiremath

Description

Problem

When using Google Vertex AI with a service account (GOOGLE_APPLICATION_CREDENTIALS pointing to a service account JSON), the custom fetch handler in provider.ts fails with:

invalid_scope: Invalid OAuth scope or ID token audience provided

This happens because new GoogleAuth() is called without specifying OAuth scopes.

Service account credentials require explicit scopes to obtain an access token — unlike user credentials (from gcloud auth application-default login) which have scopes embedded in the refresh token and work without this argument.

Plugins

No response

OpenCode version

1.2.10

Steps to reproduce

  1. Set up Google Cloud service account credentials:
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json"
export GOOGLE_CLOUD_PROJECT="your-gcp-project-id"
  1. Configure a google-vertex provider model in opencode.json:
{
  "provider": {
    "google-vertex": {
      "models": {
        "zai-org/glm-5-maas": {
          "name": "GLM-5"
        }
      }
    }
  }
}
  1. Run any prompt using the model:
    opencode run "hello" --model google-vertex/zai-org/glm-5-maas
  2. Observe error:
    invalid_scope: Invalid OAuth scope or ID token audience provided

Note: This does not reproduce if you authenticated via gcloud auth application-default login (user credentials). Only service account JSON auth is affected

Screenshot and/or share link

No response

Operating System

macOS 15.7.3 (Sequoia)

Terminal

iTerm2

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions