Skip to main content

Function: getSession()

getSession(providerId, scopes, options)

getSession(providerId, scopes, options): Promise<AuthenticationSession | undefined>

Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not registered, or if the user does not consent to sharing authentication information with the extension. If there are multiple sessions with the same scopes, the user will be shown a quickpick to select which account they would like to use.

Currently, there are only two authentication providers that are contributed from built in extensions to VS Code that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.

Parameters

providerId: string

The id of the provider to use

scopes: string[]

A list of scopes representing the permissions requested. These are dependent on the authentication provider

options: AuthenticationGetSessionOptions & object

The getSessionOptions to use

Returns

Promise<AuthenticationSession | undefined>

A promise that resolves to an authentication session

Defined in

packages/extension-api/src/extension-api.d.ts:3914

getSession(providerId, scopes, options)

getSession(providerId, scopes, options?): Promise<AuthenticationSession | undefined>

Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not registered, or if the user does not consent to sharing authentication information with the extension. If there are multiple sessions with the same scopes, the user will be shown a quickpick to select which account they would like to use.

Currently, there are only two authentication providers that are contributed from built in extensions to VS Code that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.

Parameters

providerId: string

The id of the provider to use

scopes: string[]

A list of scopes representing the permissions requested. These are dependent on the authentication provider

options?: AuthenticationGetSessionOptions

The getSessionOptions to use

Returns

Promise<AuthenticationSession | undefined>

A promise that resolves to an authentication session if available, or undefined if there are no sessions

Defined in

packages/extension-api/src/extension-api.d.ts:3933