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

Function runGcpAuthRefresh

src/utils/auth.ts:872–908  ·  view source on GitHub ↗

* Run gcpAuthRefresh to perform interactive authentication (e.g., gcloud auth application-default login) * Streams output in real-time for user visibility

()

Source from the content-addressed store, hash-verified

870 * Streams output in real-time for user visibility
871 */
872async function runGcpAuthRefresh(): Promise<boolean> {
873 const gcpAuthRefresh = getConfiguredGcpAuthRefresh()
874
875 if (!gcpAuthRefresh) {
876 return false // Not configured, treat as success
877 }
878
879 // SECURITY: Check if gcpAuthRefresh is from project settings
880 if (isGcpAuthRefreshFromProjectSettings()) {
881 // Check if trust has been established for this project
882 // Pass true to indicate this is a dangerous feature that requires trust
883 const hasTrust = checkHasTrustDialogAccepted()
884 if (!hasTrust && !getIsNonInteractiveSession()) {
885 const error = new Error(
886 `Security: gcpAuthRefresh executed before workspace trust is confirmed. If you see this message, post in ${MACRO.FEEDBACK_CHANNEL}.`,
887 )
888 logAntError('gcpAuthRefresh invoked before trust check', error)
889 logEvent('tengu_gcpAuthRefresh_missing_trust', {})
890 return false
891 }
892 }
893
894 try {
895 logForDebugging('Checking GCP credentials validity for auth refresh')
896 const isValid = await checkGcpCredentialsValid()
897 if (isValid) {
898 logForDebugging(
899 'GCP credentials are valid, skipping auth refresh command',
900 )
901 return false
902 }
903 } catch {
904 // Credentials check failed, proceed with refresh
905 }
906
907 return refreshGcpAuth(gcpAuthRefresh)
908}
909
910// Timeout for GCP auth refresh command (3 minutes).
911// Long enough for browser-based auth flows, short enough to prevent indefinite hangs.

Callers 1

auth.tsFile · 0.85

Calls 9

logAntErrorFunction · 0.85
logEventFunction · 0.85
checkGcpCredentialsValidFunction · 0.85
refreshGcpAuthFunction · 0.85
logForDebuggingFunction · 0.70

Tested by

no test coverage detected