Skip to content

Commit 2972ae0

Browse files
committed
Fix that damn bug
1 parent 810abbe commit 2972ae0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

extensions/gitpod/src/auth.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ export async function checkScopes(accessToken: string): Promise<string[]> {
364364
* Creates a URL to be opened for the whole OAuth2 flow to kick-off
365365
* @returns a `URL` string containing the whole auth URL
366366
*/
367-
async function createOauth2URL(context: vscode.ExtensionContext, options: { authorizationURI: string, clientID: string, redirectURI: vscode.Uri, scopes: string[] }): Promise<vscode.Uri> {
367+
async function createOauth2URL(context: vscode.ExtensionContext, options: { authorizationURI: string, clientID: string, redirectURI: vscode.Uri, scopes: string[] }): Promise<string> {
368368
const { authorizationURI, clientID, redirectURI, scopes } = options;
369369
const { codeChallenge, codeVerifier }: { codeChallenge: string, codeVerifier: string } = create();
370370

@@ -379,14 +379,14 @@ async function createOauth2URL(context: vscode.ExtensionContext, options: { auth
379379
}
380380

381381
set('client_id', clientID);
382-
set('redirect_uri', redirectURI.toString());
382+
set('redirect_uri', (redirectURI.toString(true)));
383383
set('response_type', 'code');
384384
set('scope', scopes.join(' '));
385385
set('code_challenge', codeChallenge);
386386
set('code_challenge_method', 'S256');
387387

388388
await context.secrets.store('gitpod.code_verifier', codeVerifier);
389-
return vscode.Uri.parse(authorizationURI).with({ query });
389+
return `${authorizationURI}?${query}`;
390390
}
391391

392392
/**
@@ -411,7 +411,6 @@ async function askToEnable(context: vscode.ExtensionContext): Promise<void> {
411411
*/
412412
export async function createSession(scopes: readonly string[], context: vscode.ExtensionContext): Promise<vscode.AuthenticationSession> {
413413
const callbackUri = await vscode.env.asExternalUri(vscode.Uri.parse(`${vscode.env.uriScheme}://gitpod.gitpod-desktop/complete-gitpod-auth`));
414-
415414
if (![...gitpodScopes].every((scope) => scopes.includes(scope))) {
416415
vscode.window.showErrorMessage('The provided scopes are not enough to turn on Settings Sync');
417416
}
@@ -430,12 +429,12 @@ export async function createSession(scopes: readonly string[], context: vscode.E
430429
reject('Login timed out.');
431430
}, 1000 * 60 * 5); // 5 minutes
432431
});
433-
434-
const opened = await vscode.env.openExternal(gitpodAuth);
432+
console.log(gitpodAuth);
433+
const opened = await vscode.env.openExternal(gitpodAuth as any);
435434
if (!opened) {
436-
const selected = await vscode.window.showErrorMessage(`Couldn't open ${gitpodAuth.toString(true)} automatically, please copy and paste it to your browser manually.`, 'Copy', 'Cancel');
435+
const selected = await vscode.window.showErrorMessage(`Couldn't open ${gitpodAuth} automatically, please copy and paste it to your browser manually.`, 'Copy', 'Cancel');
437436
if (selected === 'Copy') {
438-
vscode.env.clipboard.writeText(gitpodAuth.toString(true));
437+
vscode.env.clipboard.writeText(gitpodAuth);
439438
console.log('Copied auth URL');
440439
}
441440
}

0 commit comments

Comments
 (0)