@@ -212,7 +212,6 @@ export class CredentialStore extends Disposable {
212212 }
213213
214214 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 ) ;
216215 let enterprise : AuthResult | undefined ;
217216 const initializeEnterprise = ( ) => this . initialize ( AuthProvider . githubEnterprise , options , additionalScopes ? SCOPES_WITH_ADDITIONAL : undefined , additionalScopes ) ;
218217 if ( hasEnterpriseUri ( ) ) {
@@ -227,8 +226,12 @@ export class CredentialStore extends Disposable {
227226 } ) ;
228227 this . context . subscriptions . push ( disposable ) ;
229228 }
229+ let github : AuthResult | undefined ;
230+ if ( ! enterprise ) {
231+ github = await this . initialize ( AuthProvider . github , options , additionalScopes ? SCOPES_WITH_ADDITIONAL : undefined , additionalScopes ) ;
232+ }
230233 return {
231- canceled : github . canceled || ! ! ( enterprise && enterprise . canceled )
234+ canceled : ! ! ( github && github . canceled ) || ! ! ( enterprise && enterprise . canceled )
232235 } ;
233236 }
234237
@@ -438,14 +441,20 @@ export class CredentialStore extends Disposable {
438441 private async createHub ( token : string , authProviderId : AuthProvider ) : Promise < GitHub > {
439442 let baseUrl = 'https://api.github.com' ;
440443 let enterpriseServerUri : vscode . Uri | undefined ;
444+ Logger . appendLine ( `Creating hub for ${ isEnterprise ( authProviderId ) ? 'enterprise' : '.com' } ` , CredentialStore . ID ) ;
441445 if ( isEnterprise ( authProviderId ) ) {
442446 enterpriseServerUri = getEnterpriseUri ( ) ;
443447 }
444448
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+ }
449458 }
450459
451460 let fetchCore : ( ( url : string , options : { headers ?: Record < string , string > } ) => any ) | undefined ;
@@ -470,12 +479,13 @@ export class CredentialStore extends Disposable {
470479 baseUrl : baseUrl ,
471480 } ) ;
472481
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` ;
475485 }
476486
477487 const graphql = new ApolloClient ( {
478- link : link ( baseUrl , token || '' ) ,
488+ link : link ( graphQLBaseUrl , token || '' ) ,
479489 cache : new InMemoryCache ( ) ,
480490 defaultOptions : {
481491 query : {
0 commit comments