From 3668a573adf3585d7733791069e1c59db3142cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Wed, 21 Apr 2021 10:06:21 +0200 Subject: [PATCH] gh auth: fix staging server selection --- extensions/github-authentication/src/githubServer.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/extensions/github-authentication/src/githubServer.ts b/extensions/github-authentication/src/githubServer.ts index bcab5e06b9b..bc27d5e1646 100644 --- a/extensions/github-authentication/src/githubServer.ts +++ b/extensions/github-authentication/src/githubServer.ts @@ -54,7 +54,11 @@ export class GitHubServer { this.updateStatusBarItem(true); const state = uuid(); - const callbackUri = await vscode.env.asExternalUri(vscode.Uri.parse(`${vscode.env.uriScheme}://vscode.github-authentication/did-authenticate`)); + let callbackUri = await vscode.env.asExternalUri(vscode.Uri.parse(`${vscode.env.uriScheme}://vscode.github-authentication/did-authenticate`)); + + // TODO@joaomoreno TODO@RMacfarlane + const staging = callbackUri.scheme === 'https' && /^vscode\./.test(callbackUri.authority); + callbackUri = await vscode.env.asExternalUri(vscode.Uri.parse(`${vscode.env.uriScheme}://vscode.github-authentication/did-authenticate${staging ? '?staging=true' : ''}`)); if (this.isTestEnvironment(callbackUri)) { const token = await vscode.window.showInputBox({ prompt: 'GitHub Personal Access Token', ignoreFocusOut: true }); @@ -81,8 +85,6 @@ export class GitHubServer { const existingStates = this._pendingStates.get(scopes) || []; this._pendingStates.set(scopes, [...existingStates, state]); - // TODO@joaomoreno TODO@RMacfarlane - const staging = callbackUri.scheme === 'https' && /^vscode\./.test(callbackUri.authority); const uri = vscode.Uri.parse(`https://${staging ? AUTH_RELAY_STAGING_SERVER : AUTH_RELAY_SERVER}/authorize/?callbackUri=${encodeURIComponent(callbackUri.toString())}&scope=${scopes}&state=${state}&responseType=code&authServer=https://github.com${staging ? '&staging=true' : ''}`); await vscode.env.openExternal(uri); }