mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-06 09:03:07 -07:00
Use Env Var directly instead of through GoogleAuth() (#1202)
This commit is contained in:
committed by
GitHub
parent
0c6aa35221
commit
2de76a774d
@@ -4,7 +4,6 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { GoogleAuth, AuthClient } from 'google-auth-library';
|
||||
import { ContentGenerator } from '../core/contentGenerator.js';
|
||||
import { getOauthClient } from './oauth2.js';
|
||||
import { setupUser } from './setup.js';
|
||||
@@ -13,17 +12,7 @@ import { CodeAssistServer, HttpOptions } from './server.js';
|
||||
export async function createCodeAssistContentGenerator(
|
||||
httpOptions: HttpOptions,
|
||||
): Promise<ContentGenerator> {
|
||||
const authClient = await getAuthClient();
|
||||
const authClient = await getOauthClient();
|
||||
const projectId = await setupUser(authClient);
|
||||
return new CodeAssistServer(authClient, projectId, httpOptions);
|
||||
}
|
||||
|
||||
async function getAuthClient(): Promise<AuthClient> {
|
||||
try {
|
||||
// Try for Application Default Credentials.
|
||||
return await new GoogleAuth().getClient();
|
||||
} catch (_) {
|
||||
// No Application Default Credentials so try Oauth.
|
||||
return await getOauthClient();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user