@@ -252,10 +252,11 @@ async function createApiWebSocket(accessToken: string): Promise<{ gitpodService:
252
252
}
253
253
}
254
254
const webSocketMaxRetries = 3 ;
255
+ console . log ( `Endpoint: ${ getBaseURL ( ) . replace ( 'https' , 'wss' ) } ` ) ;
255
256
const webSocket = new ReconnectingWebSocket ( getBaseURL ( ) . replace ( 'https' , 'wss' ) , undefined , {
256
257
minReconnectionDelay : 1000 ,
257
258
connectionTimeout : 10000 ,
258
- maxRetries : webSocketMaxRetries ,
259
+ maxRetries : webSocketMaxRetries - 1 ,
259
260
debug : false ,
260
261
startClosed : false ,
261
262
WebSocket : GitpodServerWebSocket
@@ -295,29 +296,21 @@ interface ExchangeTokenResponse {
295
296
* @returns a promise that resolves with the authentication session
296
297
*/
297
298
export async function resolveAuthenticationSession ( scopes : readonly string [ ] , code : string , context : vscode . ExtensionContext ) : Promise < vscode . AuthenticationSession | null > {
298
-
299
+ const callbackUri = ( await vscode . env . asExternalUri ( vscode . Uri . parse ( ` ${ vscode . env . uriScheme } ://gitpod.gitpod-desktop/complete-gitpod-auth` ) ) ) . toString ( true ) ;
299
300
try {
300
- console . log ( 'Making token request with ' ) ;
301
- console . log ( new URLSearchParams ( {
302
- code,
303
- grant_type : 'authorization_code' ,
304
- client_id : `${ vscode . env . uriScheme } -gitpod` ,
305
- redirect_uri : 'vscode://gitpod.gitpod-desktop/complete-gitpod-auth' ,
306
- code_verifier : await context . secrets . get ( 'gitpod.code_verifier' )
307
- } ) ) ;
308
301
const exchangeTokenResponse = await fetch ( `${ getBaseURL ( ) } /api/oauth/token` , {
309
302
method : 'POST' ,
310
303
body : new URLSearchParams ( {
311
304
code,
312
305
grant_type : 'authorization_code' ,
313
306
client_id : `${ vscode . env . uriScheme } -gitpod` ,
314
- redirect_uri : 'vscode://gitpod.gitpod-desktop/complete-gitpod-auth' ,
307
+ redirect_uri : callbackUri ,
315
308
code_verifier : await context . secrets . get ( 'gitpod.code_verifier' )
316
309
} )
317
310
} ) ;
318
311
319
312
if ( ! exchangeTokenResponse . ok ) {
320
- vscode . window . showErrorMessage ( `Couldn't connect: ${ exchangeTokenResponse . statusText } ` ) ;
313
+ vscode . window . showErrorMessage ( `Couldn't connect: ${ exchangeTokenResponse . statusText } , ${ await exchangeTokenResponse . text ( ) } ` ) ;
321
314
return null ;
322
315
}
323
316
0 commit comments