@@ -40,6 +40,16 @@ declare module 'vscode' {
4040 readonly label : string ;
4141 }
4242
43+ /**
44+ * Optional options to be used when calling {@link authentication.getSession} with the flag `forceNewSession`.
45+ */
46+ export interface AuthenticationForceNewSessionOptions {
47+ /**
48+ * An optional message that will be displayed to the user when we ask to re-authenticate. Providing additional context
49+ * as to why you are asking a user to re-authenticate can help increase the odds that they will accept.
50+ */
51+ detail ?: string ;
52+ }
4353
4454 /**
4555 * Options to be used when getting an {@link AuthenticationSession} from an {@link AuthenticationProvider}.
@@ -60,14 +70,17 @@ declare module 'vscode' {
6070 createIfNone ?: boolean ;
6171
6272 /**
63- * Whether we should attempt to reauthenticate even if there is already a session available.
64- *
65- * If true, a modal dialog will be shown asking the user to sign in again. This is mostly used for scenarios
66- * where the token needs to be re minted because it has lost some authorization.
67- *
68- * Defaults to false.
69- */
70- forceNewSession ?: boolean | { detail : string } ;
73+ * Whether we should attempt to reauthenticate even if there is already a session available.
74+ *
75+ * If true, a modal dialog will be shown asking the user to sign in again. This is mostly used for scenarios
76+ * where the token needs to be re minted because it has lost some authorization.
77+ *
78+ * If there are no existing sessions and forceNewSession is true, it will behave identically to
79+ * {@link AuthenticationGetSessionOptions.createIfNone createIfNone}.
80+ *
81+ * This defaults to false.
82+ */
83+ forceNewSession ?: boolean | AuthenticationForceNewSessionOptions ;
7184
7285
7386 /**
@@ -202,34 +215,49 @@ declare module 'vscode' {
202215 */
203216 export namespace authentication {
204217 /**
205- * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
206- * registered, or if the user does not consent to sharing authentication information with
207- * the extension. If there are multiple sessions with the same scopes, the user will be shown a
208- * quickpick to select which account they would like to use.
209- *
210- * Currently, there are only two authentication providers that are contributed from built in extensions
211- * to VS Code that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
212- * @param providerId The id of the provider to use
213- * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
214- * @param options The {@link GetSessionOptions } to use
215- * @returns A thenable that resolves to an authentication session
216- */
217- export function getSession ( providerId : string , scopes : string [ ] , options : AuthenticationGetSessionOptions & { createIfNone : true } ) : Thenable < AuthenticationSession > ;
218+ * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
219+ * registered, or if the user does not consent to sharing authentication information with
220+ * the extension. If there are multiple sessions with the same scopes, the user will be shown a
221+ * quickpick to select which account they would like to use.
222+ *
223+ * Currently, there are only two authentication providers that are contributed from built in extensions
224+ * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
225+ * @param providerId The id of the provider to use
226+ * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
227+ * @param options The {@link AuthenticationGetSessionOptions } to use
228+ * @returns A thenable that resolves to an authentication session
229+ */
230+ export function getSession ( providerId : string , scopes : readonly string [ ] , options : AuthenticationGetSessionOptions & { /** */ createIfNone : true } ) : Thenable < AuthenticationSession > ;
218231
219- /**
220- * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
221- * registered, or if the user does not consent to sharing authentication information with
222- * the extension. If there are multiple sessions with the same scopes, the user will be shown a
223- * quickpick to select which account they would like to use.
224- *
225- * Currently, there are only two authentication providers that are contributed from built in extensions
226- * to VS Code that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
227- * @param providerId The id of the provider to use
228- * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
229- * @param options The {@link GetSessionOptions} to use
230- * @returns A thenable that resolves to an authentication session if available, or undefined if there are no sessions
231- */
232- export function getSession ( providerId : string , scopes : string [ ] , options ?: AuthenticationGetSessionOptions ) : Thenable < AuthenticationSession | undefined > ;
232+ /**
233+ * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
234+ * registered, or if the user does not consent to sharing authentication information with
235+ * the extension. If there are multiple sessions with the same scopes, the user will be shown a
236+ * quickpick to select which account they would like to use.
237+ *
238+ * Currently, there are only two authentication providers that are contributed from built in extensions
239+ * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
240+ * @param providerId The id of the provider to use
241+ * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
242+ * @param options The {@link AuthenticationGetSessionOptions} to use
243+ * @returns A thenable that resolves to an authentication session
244+ */
245+ export function getSession ( providerId : string , scopes : readonly string [ ] , options : AuthenticationGetSessionOptions & { /** literal-type defines return type */ forceNewSession : true | AuthenticationForceNewSessionOptions } ) : Thenable < AuthenticationSession > ;
246+
247+ /**
248+ * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
249+ * registered, or if the user does not consent to sharing authentication information with
250+ * the extension. If there are multiple sessions with the same scopes, the user will be shown a
251+ * quickpick to select which account they would like to use.
252+ *
253+ * Currently, there are only two authentication providers that are contributed from built in extensions
254+ * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
255+ * @param providerId The id of the provider to use
256+ * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
257+ * @param options The {@link AuthenticationGetSessionOptions} to use
258+ * @returns A thenable that resolves to an authentication session if available, or undefined if there are no sessions
259+ */
260+ export function getSession ( providerId : string , scopes : readonly string [ ] , options ?: AuthenticationGetSessionOptions ) : Thenable < AuthenticationSession | undefined > ;
233261
234262 /**
235263 * An {@link Event} which fires when the authentication sessions of an authentication provider have
0 commit comments