MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / checkGcpCredentialsValid

Function checkGcpCredentialsValid

src/utils/auth.ts:844–863  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

842 * This uses the same authentication chain that the Vertex SDK uses.
843 */
844export async function checkGcpCredentialsValid(): Promise<boolean> {
845 try {
846 // Dynamically import to avoid loading google-auth-library unnecessarily
847 const { GoogleAuth } = await import('google-auth-library')
848 const auth = new GoogleAuth({
849 scopes: ['https://www.googleapis.com/auth/cloud-platform'],
850 })
851 const probe = (async () => {
852 const client = await auth.getClient()
853 await client.getAccessToken()
854 })()
855 const timeout = sleep(GCP_CREDENTIALS_CHECK_TIMEOUT_MS).then(() => {
856 throw new GcpCredentialsTimeoutError('GCP credentials check timed out')
857 })
858 await Promise.race([probe, timeout])
859 return true
860 } catch {
861 return false
862 }
863}
864
865/** Default GCP credential TTL - 1 hour to match typical ADC token lifetime */
866const DEFAULT_GCP_CREDENTIAL_TTL = 60 * 60 * 1000

Callers 1

runGcpAuthRefreshFunction · 0.85

Calls 1

sleepFunction · 0.70

Tested by

no test coverage detected