@@ -212,7 +212,6 @@ export class CredentialStore extends Disposable {
212
212
}
213
213
214
214
private async doCreate ( options : vscode . AuthenticationGetSessionOptions , additionalScopes : boolean = false ) : Promise < AuthResult > {
215
- const github = await this . initialize ( AuthProvider . github , options , additionalScopes ? SCOPES_WITH_ADDITIONAL : undefined , additionalScopes ) ;
216
215
let enterprise : AuthResult | undefined ;
217
216
const initializeEnterprise = ( ) => this . initialize ( AuthProvider . githubEnterprise , options , additionalScopes ? SCOPES_WITH_ADDITIONAL : undefined , additionalScopes ) ;
218
217
if ( hasEnterpriseUri ( ) ) {
@@ -227,8 +226,12 @@ export class CredentialStore extends Disposable {
227
226
} ) ;
228
227
this . context . subscriptions . push ( disposable ) ;
229
228
}
229
+ let github : AuthResult | undefined ;
230
+ if ( ! enterprise ) {
231
+ github = await this . initialize ( AuthProvider . github , options , additionalScopes ? SCOPES_WITH_ADDITIONAL : undefined , additionalScopes ) ;
232
+ }
230
233
return {
231
- canceled : github . canceled || ! ! ( enterprise && enterprise . canceled )
234
+ canceled : ! ! ( github && github . canceled ) || ! ! ( enterprise && enterprise . canceled )
232
235
} ;
233
236
}
234
237
@@ -438,14 +441,20 @@ export class CredentialStore extends Disposable {
438
441
private async createHub ( token : string , authProviderId : AuthProvider ) : Promise < GitHub > {
439
442
let baseUrl = 'https://api.github.com' ;
440
443
let enterpriseServerUri : vscode . Uri | undefined ;
444
+ Logger . appendLine ( `Creating hub for ${ isEnterprise ( authProviderId ) ? 'enterprise' : '.com' } ` , CredentialStore . ID ) ;
441
445
if ( isEnterprise ( authProviderId ) ) {
442
446
enterpriseServerUri = getEnterpriseUri ( ) ;
443
447
}
444
448
445
- if ( enterpriseServerUri && enterpriseServerUri . authority . endsWith ( 'ghe.com' ) ) {
446
- baseUrl = `${ enterpriseServerUri . scheme } ://api.${ enterpriseServerUri . authority } ` ;
447
- } else if ( enterpriseServerUri ) {
448
- baseUrl = `${ enterpriseServerUri . scheme } ://${ enterpriseServerUri . authority } /api/v3` ;
449
+ const isGhe = enterpriseServerUri ?. authority . endsWith ( 'ghe.com' ) ;
450
+
451
+ if ( enterpriseServerUri ) {
452
+ Logger . appendLine ( `Enterprise server authority ${ enterpriseServerUri . authority } ` , CredentialStore . ID ) ;
453
+ if ( isGhe ) {
454
+ baseUrl = `${ enterpriseServerUri . scheme } ://api.${ enterpriseServerUri . authority } ` ;
455
+ } else {
456
+ baseUrl = `${ enterpriseServerUri . scheme } ://${ enterpriseServerUri . authority } /api/v3` ;
457
+ }
449
458
}
450
459
451
460
let fetchCore : ( ( url : string , options : { headers ?: Record < string , string > } ) => any ) | undefined ;
@@ -470,12 +479,13 @@ export class CredentialStore extends Disposable {
470
479
baseUrl : baseUrl ,
471
480
} ) ;
472
481
473
- if ( enterpriseServerUri ) {
474
- baseUrl = `${ enterpriseServerUri . scheme } ://${ enterpriseServerUri . authority } /api` ;
482
+ let graphQLBaseUrl = baseUrl ;
483
+ if ( enterpriseServerUri && ! isGhe ) {
484
+ graphQLBaseUrl = `${ enterpriseServerUri . scheme } ://${ enterpriseServerUri . authority } /api` ;
475
485
}
476
486
477
487
const graphql = new ApolloClient ( {
478
- link : link ( baseUrl , token || '' ) ,
488
+ link : link ( graphQLBaseUrl , token || '' ) ,
479
489
cache : new InMemoryCache ( ) ,
480
490
defaultOptions : {
481
491
query : {
0 commit comments