diff options
| author | N. Taylor Mullen <[email protected]> | 2025-07-12 15:42:47 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-12 15:42:47 -0700 |
| commit | 4442e893c367a901a4c801816e0ade5b78c291c9 (patch) | |
| tree | a5962bb7e5995e33306bd33635f25f889f5c4b52 /packages/core/src/code_assist/oauth2.ts | |
| parent | 890982a811e22de9525148e6c28f39bfbf10a49a (diff) | |
fix(auth): Remove sharp edges from headless auth (#3985)
Diffstat (limited to 'packages/core/src/code_assist/oauth2.ts')
| -rw-r--r-- | packages/core/src/code_assist/oauth2.ts | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/packages/core/src/code_assist/oauth2.ts b/packages/core/src/code_assist/oauth2.ts index d5f28880..48449b5e 100644 --- a/packages/core/src/code_assist/oauth2.ts +++ b/packages/core/src/code_assist/oauth2.ts @@ -163,38 +163,35 @@ async function authWithUserCode(client: OAuth2Client): Promise<boolean> { code_challenge: codeVerifier.codeChallenge, state, }); - console.error('Please visit the following URL to authorize the application:'); - console.error(''); - console.error(authUrl); - console.error(''); + console.log('Please visit the following URL to authorize the application:'); + console.log(''); + console.log(authUrl); + console.log(''); const code = await new Promise<string>((resolve) => { const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); - rl.question('Enter the authorization code: ', (answer) => { + rl.question('Enter the authorization code: ', (code) => { rl.close(); - resolve(answer.trim()); + resolve(code.trim()); }); }); if (!code) { console.error('Authorization code is required.'); return false; - } else { - console.error(`Received authorization code: "${code}"`); } try { - const response = await client.getToken({ + const { tokens } = await client.getToken({ code, codeVerifier: codeVerifier.codeVerifier, redirect_uri: redirectUri, }); - client.setCredentials(response.tokens); + client.setCredentials(tokens); } catch (_error) { - // Consider logging the error. return false; } return true; |
