@@ -25,7 +25,8 @@ const PROMPT_FOR_SIGN_IN_SCOPE = 'prompt for sign in';
25
25
const PROMPT_FOR_SIGN_IN_STORAGE_KEY = 'login' ;
26
26
27
27
// 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' ] ;
29
30
30
31
export enum AuthProvider {
31
32
github = 'github' ,
@@ -81,7 +82,7 @@ export class CredentialStore implements vscode.Disposable {
81
82
getAuthSessionOptions = { ...getAuthSessionOptions , ...{ createIfNone : false } } ;
82
83
let session ;
83
84
try {
84
- session = await vscode . authentication . getSession ( authProviderId , SCOPES , getAuthSessionOptions ) ;
85
+ session = await this . getSession ( authProviderId , getAuthSessionOptions ) ;
85
86
} catch ( e ) {
86
87
if ( getAuthSessionOptions . forceNewSession && ( e . message === 'User did not consent to login.' ) ) {
87
88
// 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 {
257
258
github . currentUser = user . data ;
258
259
}
259
260
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
+
260
269
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 } ) ) ! ;
262
271
if ( authProviderId === AuthProvider . github ) {
263
272
this . _sessionId = session . id ;
264
273
} else {
0 commit comments