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); }