@@ -136,7 +136,7 @@ const newConfig = {
136
136
canSwitch : true ,
137
137
authenticationProviders : {
138
138
gitpod : {
139
- scopes : [ ... gitpodScopes ]
139
+ scopes : [ 'function:accessCodeSyncStorage' ]
140
140
}
141
141
}
142
142
} ;
@@ -316,11 +316,10 @@ export async function resolveAuthenticationSession(scopes: readonly string[], co
316
316
317
317
const exchangeTokenData : ExchangeTokenResponse = await exchangeTokenResponse . json ( ) ;
318
318
console . log ( exchangeTokenData ) ;
319
- const access_token = exchangeTokenData . access_token ;
319
+ const jwtToken = exchangeTokenData . access_token ;
320
+ const accessToken = JSON . parse ( Buffer . from ( jwtToken . split ( '.' ) [ 1 ] , 'base64' ) . toString ( ) ) [ 'jti' ] ;
320
321
321
- console . log ( access_token ) ;
322
-
323
- const { gitpodService, pendignWebSocket } = await createApiWebSocket ( access_token ) ;
322
+ const { gitpodService, pendignWebSocket } = await createApiWebSocket ( accessToken ) ;
324
323
const user = await gitpodService . server . getLoggedInUser ( ) ;
325
324
( await pendignWebSocket ) . close ( ) ;
326
325
return {
@@ -329,8 +328,8 @@ export async function resolveAuthenticationSession(scopes: readonly string[], co
329
328
label : user . name ! ,
330
329
id : user . id
331
330
} ,
332
- scopes : scopes ,
333
- accessToken : access_token
331
+ scopes,
332
+ accessToken
334
333
} ;
335
334
} catch ( e ) {
336
335
vscode . window . showErrorMessage ( `Couldn't connect: ${ e } ` ) ;
@@ -405,8 +404,8 @@ async function askToEnable(context: vscode.ExtensionContext): Promise<void> {
405
404
*/
406
405
export async function createSession ( scopes : readonly string [ ] , context : vscode . ExtensionContext ) : Promise < vscode . AuthenticationSession > {
407
406
const callbackUri = await vscode . env . asExternalUri ( vscode . Uri . parse ( `${ vscode . env . uriScheme } ://gitpod.gitpod-desktop/complete-gitpod-auth` ) ) ;
408
- if ( ! [ ... gitpodScopes ] . every ( ( scope ) => scopes . includes ( scope ) ) ) {
409
- vscode . window . showErrorMessage ( 'The provided scopes are not enough to turn on Settings Sync ') ;
407
+ if ( scopes . some ( scope => ! gitpodScopes . has ( scope ) ) ) {
408
+ throw new Error ( 'invalid scopes') ;
410
409
}
411
410
412
411
const gitpodAuth = await createOauth2URL ( context , {
0 commit comments