@@ -151,14 +151,22 @@ export class IntegrationService implements Disposable {
151151
152152 try {
153153 const exchangeToken = await this . container . accountAuthentication . getExchangeToken ( ) ;
154- await openUrl (
155- this . container
156- . getGkDevExchangeUri ( exchangeToken , `settings/integrations?source=gitlens` )
157- . toString ( true ) ,
158- ) ;
154+ if (
155+ ! ( await openUrl (
156+ this . container
157+ . getGkDevUri ( 'settings/integrations' , `source=gitlens&token=${ exchangeToken } ` )
158+ . toString ( true ) ,
159+ ) )
160+ ) {
161+ return ;
162+ }
159163 } catch ( ex ) {
160164 Logger . error ( ex , scope ) ;
161- await env . openExternal ( this . container . getGkDevUri ( 'settings/integrations' , 'source=gitlens' ) ) ;
165+ if (
166+ ! ( await openUrl ( this . container . getGkDevUri ( 'settings/integrations' , 'source=gitlens' ) . toString ( true ) ) )
167+ ) {
168+ return ;
169+ }
162170 }
163171 take (
164172 window . onDidChangeWindowState ,
@@ -238,31 +246,31 @@ export class IntegrationService implements Disposable {
238246 }
239247 }
240248
241- const callbackUri = await env . asExternalUri (
242- Uri . parse (
243- `${ env . uriScheme } ://${ this . container . context . extension . id } /${ CloudIntegrationAuthenticationUriPathPrefix } ` ,
244- ) ,
245- ) ;
246- query += `&redirect_uri=${ encodeURIComponent ( callbackUri . toString ( true ) ) } ` ;
247-
248- if ( account != null ) {
249- try {
250- const exchangeToken = await this . container . accountAuthentication . getExchangeToken ( ) ;
251- if (
252- ! ( await openUrl (
253- this . container . getGkDevExchangeUri ( exchangeToken , `connect?${ query } ` ) . toString ( true ) ,
254- ) )
255- ) {
256- return false ;
257- }
258- } catch ( ex ) {
259- Logger . error ( ex , scope ) ;
260- if ( ! ( await openUrl ( this . container . getGkDevUri ( 'connect' , query ) . toString ( true ) ) ) ) {
261- return false ;
262- }
249+ const baseQuery = query ;
250+ try {
251+ if ( account != null ) {
252+ const token = await this . container . accountAuthentication . getExchangeToken (
253+ CloudIntegrationAuthenticationUriPathPrefix ,
254+ ) ;
255+
256+ query += `&token=${ token } ` ;
257+ } else {
258+ const callbackUri = await env . asExternalUri (
259+ Uri . parse (
260+ `${ env . uriScheme } ://${ this . container . context . extension . id } /${ CloudIntegrationAuthenticationUriPathPrefix } ` ,
261+ ) ,
262+ ) ;
263+ query += `&redirect_uri=${ encodeURIComponent ( callbackUri . toString ( true ) ) } ` ;
264+ }
265+
266+ if ( ! ( await openUrl ( this . container . getGkDevUri ( 'connect' , query ) . toString ( true ) ) ) ) {
267+ return false ;
268+ }
269+ } catch ( ex ) {
270+ Logger . error ( ex , scope ) ;
271+ if ( ! ( await openUrl ( this . container . getGkDevUri ( 'connect' , baseQuery ) . toString ( true ) ) ) ) {
272+ return false ;
263273 }
264- } else if ( ! ( await openUrl ( this . container . getGkDevUri ( 'connect' , query ) . toString ( true ) ) ) ) {
265- return false ;
266274 }
267275
268276 const deferredCallback = promisifyDeferred < Uri , string | undefined > (
0 commit comments