Skip to content

Commit 54c075c

Browse files
committed
pass oauth client through the googleAuthOptions param directly
1 parent f47d739 commit 54c075c

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

apps/sim/providers/google/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ export const googleProvider: ProviderConfig = {
3030

3131
logger.info('Creating Google Gemini client', { model: request.model })
3232

33-
// Create client with API key
3433
const ai = new GoogleGenAI({ apiKey: request.apiKey })
3534

36-
// Use shared execution logic
3735
return executeGeminiRequest({
3836
ai,
3937
model: request.model,

apps/sim/providers/vertex/index.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { GoogleGenAI } from '@google/genai'
2+
import { OAuth2Client } from 'google-auth-library'
23
import { env } from '@/lib/core/config/env'
34
import { createLogger } from '@/lib/logs/console/logger'
45
import type { StreamingExecution } from '@/executor/types'
@@ -15,9 +16,8 @@ const logger = createLogger('VertexProvider')
1516
* Shares core execution logic with Google Gemini provider.
1617
*
1718
* Authentication:
18-
* - Uses OAuth access token (from `gcloud auth print-access-token` or service account)
19-
* - Token refresh should be handled at the OAuth layer before calling this provider
20-
* - Access token is passed via HTTP Authorization header
19+
* - Uses OAuth access token passed via googleAuthOptions.authClient
20+
* - Token refresh is handled at the OAuth layer before calling this provider
2121
*/
2222
export const vertexProvider: ProviderConfig = {
2323
id: 'vertex',
@@ -54,20 +54,21 @@ export const vertexProvider: ProviderConfig = {
5454
model,
5555
})
5656

57+
// Create an OAuth2Client and set the access token
58+
// This allows us to use an OAuth access token with the SDK
59+
const authClient = new OAuth2Client()
60+
authClient.setCredentials({ access_token: request.apiKey })
61+
5762
// Create client with Vertex AI configuration
58-
// Pass access token via HTTP Authorization header
5963
const ai = new GoogleGenAI({
6064
vertexai: true,
6165
project: vertexProject,
6266
location: vertexLocation,
63-
httpOptions: {
64-
headers: {
65-
Authorization: `Bearer ${request.apiKey}`,
66-
},
67+
googleAuthOptions: {
68+
authClient,
6769
},
6870
})
6971

70-
// Use shared execution logic
7172
return executeGeminiRequest({
7273
ai,
7374
model,

0 commit comments

Comments
 (0)