@@ -25,7 +25,8 @@ const PROMPT_FOR_SIGN_IN_SCOPE = 'prompt for sign in';
2525const PROMPT_FOR_SIGN_IN_STORAGE_KEY = 'login' ;
2626
2727// If the scopes are changed, make sure to notify all interested parties to make sure this won't cause problems.
28- const SCOPES = [ 'read:user' , 'user:email' , 'repo' ] ;
28+ const SCOPES_OLD = [ 'read:user' , 'user:email' , 'repo' ] ;
29+ const SCOPES = [ 'read:user' , 'user:email' , 'repo' , 'workflow' ] ;
2930
3031export enum AuthProvider {
3132 github = 'github' ,
@@ -81,7 +82,7 @@ export class CredentialStore implements vscode.Disposable {
8182 getAuthSessionOptions = { ...getAuthSessionOptions , ...{ createIfNone : false } } ;
8283 let session ;
8384 try {
84- session = await vscode . authentication . getSession ( authProviderId , SCOPES , getAuthSessionOptions ) ;
85+ session = await this . getSession ( authProviderId , getAuthSessionOptions ) ;
8586 } catch ( e ) {
8687 if ( getAuthSessionOptions . forceNewSession && ( e . message === 'User did not consent to login.' ) ) {
8788 // There are cases where a forced login may not be 100% needed, so just continue as usual if
@@ -257,8 +258,16 @@ export class CredentialStore implements vscode.Disposable {
257258 github . currentUser = user . data ;
258259 }
259260
261+ private async getSession ( authProviderId : AuthProvider , getAuthSessionOptions : vscode . AuthenticationGetSessionOptions ) {
262+ let session : vscode . AuthenticationSession | undefined = await vscode . authentication . getSession ( authProviderId , SCOPES , { silent : true } ) ;
263+ if ( ! session ) {
264+ session = await vscode . authentication . getSession ( authProviderId , SCOPES_OLD , getAuthSessionOptions ) ;
265+ }
266+ return session ;
267+ }
268+
260269 private async getSessionOrLogin ( authProviderId : AuthProvider ) : Promise < string > {
261- const session = await vscode . authentication . getSession ( authProviderId , SCOPES , { createIfNone : true } ) ;
270+ const session = ( await this . getSession ( authProviderId , { createIfNone : true } ) ) ! ;
262271 if ( authProviderId === AuthProvider . github ) {
263272 this . _sessionId = session . id ;
264273 } else {
0 commit comments