fix(opencode): pass OAuth scopes to GoogleAuth for Vertex AI (#15110)

Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
This commit is contained in:
Saurav M H
2026-05-29 05:35:43 +05:30
committed by GitHub
parent acca8864ba
commit 797c689ec2
3 changed files with 16 additions and 11 deletions

View File

@@ -43,9 +43,9 @@ function authFetch(fetchWithRuntimeOptions?: unknown) {
// do not, so inject a Google access token into their fetch path.
return async (input: Parameters<typeof fetch>[0], init?: RequestInit) => {
const { GoogleAuth } = await import("google-auth-library")
const auth = new GoogleAuth()
const client = await auth.getApplicationDefault()
const token = await client.credential.getAccessToken()
const auth = new GoogleAuth({ scopes: ["https://www.googleapis.com/auth/cloud-platform"] })
const client = await auth.getClient()
const token = await client.getAccessToken()
const headers = new Headers(init?.headers)
headers.set("Authorization", `Bearer ${token.token}`)
return typeof fetchWithRuntimeOptions === "function"