Skip to content

API support for multiple AuthenticationSessions with the same scopes. #152399

Closed
@philliphoff

Description

@philliphoff

Currently VS Code provides an API (vscode.authentication.getSession()) that allows extensions to get an AuthenticationSession for a given set of scopes. Depending on the options passed it, if there are no existing sessions, VS Code may prompt the user to sign in. If there are more than one session with those scopes, VS Code may prompt the user to select which one to use. At the end of the day, however, the extension is returned at most one AuthenticationSession that corresponds to a single account.

In some cases extensions may want to know about all the AuthenticationSession instances associated with a specific set of scopes, in order to provide multi-account experiences or to have its own UX for choosing which account is used in a specific setting (where VS Code's current selection UX might not be appropriate). For example, a tree view that shows assets associated with multiple accounts rather than requiring the user to constantly switch between accounts.

What I propose is a new function, getSessions() with similar semantics as that same method on the AuthenticationProvider. If matching sessions exist, all will be returned. If none exist, an empty array is returned. Calling the function will not result in any user prompts (to select between accounts or to sign in) aside, perhaps, from the initial "do you allow this extension to access these accounts" prompt.

declare module 'vscode' {
    export namespace authentication {
        export function getSessions(providerId: string, scopes: readonly string[]): Thenable<readonly AuthenticationSession[]>;
    }
}

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions