@@ -19,7 +19,7 @@ import { IProductService } from 'vs/platform/product/common/productService';
1919import { IRequestService } from 'vs/platform/request/common/request' ;
2020import { CONFIGURATION_SYNC_STORE_KEY , IUserDataSyncStoreClient , SyncResource } from 'vs/platform/userDataSync/common/userDataSync' ;
2121import { URI } from 'vs/base/common/uri' ;
22- import { getCurrentAuthenticationSessionInfo } from 'vs/workbench/services/authentication/browser/authenticationService' ;
22+ import { AuthenticationSessionInfo , getCurrentAuthenticationSessionInfo } from 'vs/workbench/services/authentication/browser/authenticationService' ;
2323import { getSyncAreaLabel } from 'vs/workbench/services/userDataSync/common/userDataSync' ;
2424import { IWorkbenchContribution , IWorkbenchContributionsRegistry , Extensions } from 'vs/workbench/common/contributions' ;
2525import { Registry } from 'vs/platform/registry/common/platform' ;
@@ -80,18 +80,13 @@ export class UserDataInitializationService implements IUserDataInitializationSer
8080 return ;
8181 }
8282
83- if ( ! this . environmentService . options ?. credentialsProvider ) {
84- this . logService . trace ( `Skipping initializing user data as credentials provider is not provided` ) ;
85- return ;
86- }
83+ const authenticationSession = await this . getCurrentAuthenticationSessionInfo ( ) ;
8784
88- let authenticationSession ;
89- try {
90- authenticationSession = await getCurrentAuthenticationSessionInfo ( this . environmentService , this . productService ) ;
91- } catch ( error ) {
92- this . logService . error ( error ) ;
93- }
9485 if ( ! authenticationSession ) {
86+ if ( ! this . environmentService . options ?. credentialsProvider ) {
87+ this . logService . trace ( `Skipping initializing user data as credentials provider is not provided` ) ;
88+ return ;
89+ }
9590 this . logService . trace ( `Skipping initializing user data as authentication session is not set` ) ;
9691 return ;
9792 }
@@ -105,6 +100,35 @@ export class UserDataInitializationService implements IUserDataInitializationSer
105100 return this . _userDataSyncStoreClientPromise ;
106101 }
107102
103+ private async getCurrentAuthenticationSessionInfo ( ) : Promise < AuthenticationSessionInfo | undefined > {
104+ if ( this . environmentService . options ?. credentialsProvider ) {
105+ try {
106+ const currentAuthenticationSessionInfo = await getCurrentAuthenticationSessionInfo ( this . environmentService , this . productService ) ;
107+ if ( currentAuthenticationSessionInfo ) {
108+ return currentAuthenticationSessionInfo ;
109+ }
110+ } catch ( error ) {
111+ this . logService . error ( error ) ;
112+ return undefined ;
113+ }
114+ }
115+
116+ if ( ! this . environmentService . isBuilt ) {
117+ const authenticationSessionInfoElement = document . getElementById ( 'vscode-workbench-authentication-session' ) ;
118+ const authenticationSessionInfoElementAttribute = authenticationSessionInfoElement ? authenticationSessionInfoElement . getAttribute ( 'data-settings' ) : undefined ;
119+ if ( authenticationSessionInfoElementAttribute ) {
120+ try {
121+ return JSON . parse ( authenticationSessionInfoElementAttribute ) ;
122+ } catch ( error ) {
123+ this . logService . error ( error ) ;
124+ return undefined ;
125+ }
126+ }
127+ }
128+
129+ return undefined ;
130+ }
131+
108132 async initializeRequiredResources ( ) : Promise < void > {
109133 return this . initialize ( [ SyncResource . Settings , SyncResource . GlobalState ] ) ;
110134 }
0 commit comments