google-gemini/gemini-cli · info · ChangeAuthRequestedError
User requested to change authentication method
Error message
User requested to change authentication method
What it means
ChangeAuthRequestedError is a control-flow exception thrown inside setupUser's validation loop. It fires only after the Code Assist API returned ValidationRequiredError AND the caller's validationHandler returned the literal intent 'change_auth'. It is not a failure: it tells the outer auth layer to restart auth selection with a different credential.
Source
Thrown at packages/core/src/code_assist/setup.ts:198
...coreClientMetadata,
duetProject: projectId,
},
});
try {
validateLoadCodeAssistResponse(loadRes);
break;
} catch (e) {
if (e instanceof ValidationRequiredError && validationHandler) {
const intent = await validationHandler(
e.validationLink,
e.validationDescription,
);
if (intent === 'verify') {
continue;
}
if (intent === 'change_auth') {
throw new ChangeAuthRequestedError();
}
throw new ValidationCancelledError();
}
throw e;
}
}
if (loadRes.currentTier) {
if (!loadRes.paidTier?.id && !loadRes.currentTier.id) {
debugLogger.warn(
'Warning: Code Assist API did not return a user tier ID. Defaulting to STANDARD tier.',
);
}
if (!loadRes.cloudaicompanionProject) {
if (projectId) {
return {
projectId,View on GitHub (pinned to 5024443c72)
Solutions
- Catch ChangeAuthRequestedError at the auth-selection layer and loop back to credential choice (this is the intended handler).
- If you did not mean to switch auth, retry setupUser and pick 'verify' on the validation prompt.
- If the prompt keeps appearing, ensure the account is on a Code Assist-eligible tier before re-running.
Example fix
// before
try { await setupUser(client, config); }
catch (e) { throw e; }
// after
try { await setupUser(client, config); }
catch (e) {
if (e instanceof ChangeAuthRequestedError) { return restartAuthSelection(); }
throw e;
} Defensive patterns
Strategy: try-catch
Type guard
// node
import { ChangeAuthRequestedError } from './utils/errors.js';
function isChangeAuthRequested(e: unknown): e is ChangeAuthRequestedError {
return e instanceof ChangeAuthRequestedError;
} Try / catch
try {
await setupUser(client, config);
} catch (e) {
if (e instanceof ChangeAuthRequestedError) {
// intended: restart auth method selection
return restartAuthSelection();
}
throw e;
} Prevention
- Always wire a validationHandler so user intent is mapped to one of 'verify' | 'change_auth'.
- Treat ChangeAuthRequestedError as control flow, not a bug — never let it bubble to generic error UI.
When it happens
Trigger: setupUser() -> caServer.loadCodeAssist() throws ValidationRequiredError -> config.getValidationHandler() is set -> user picks 'change_auth' from the verificationLink/validationDescription prompt -> line 198 throws.
Common situations: User selects 'Use a different account' / 'Switch login' in the OAuth/quota verification prompt; first-time login where the default account lacks Code Assist access; switching from Vertex to Code Assist auth.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- User cancelled account validation
- Execution aborted
- Failed to initialize GCS bucket ${this.bucketName}: ${error}
- The enforced authentication type is '${enforcedType}', but t
- The auth type '${enforcedType}' is enforced, but no authenti
AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12).
Data as JSON: /api/errors/64c2bd360938b246.
Report an issue: GitHub.