Skip to content

Commit 96e3d72

Browse files
committed
Update scopes
1 parent 37dde4e commit 96e3d72

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/github/credentials.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ const PROMPT_FOR_SIGN_IN_SCOPE = 'prompt for sign in';
2525
const 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

3031
export 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

Comments
 (0)