Skip to content

Commit 1836610

Browse files
api: add optional createIfNone to AzureAuthentication.getSessionWithScopes (#1466)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ed000d0 commit 1836610

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## Unreleased
4+
5+
### Added
6+
* Add an optional `options` parameter to `AzureAuthentication.getSessionWithScopes`. Passing `{ createIfNone: true }` allows an interactive consent prompt when a session for the requested scopes has not yet been granted. See [microsoft/vscode-azurefunctions#5073](https://github.com/microsoft/vscode-azurefunctions/issues/5073)
7+
38
## 0.12.5 - 2026-05-28
49

510
### Changed

api/docs/vscode-azureresources-api.d.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,13 @@ export declare interface AzureAuthentication {
126126
*
127127
* @param scopeListOrRequest - The scopes for which the authentication is needed. Use AuthenticationWwwAuthenticateRequest for supporting challenge requests.
128128
* Note: use of AuthenticationWwwAuthenticateRequest requires VS Code v1.105.0
129+
* @param options - (Optional) Options controlling how the session is acquired. By default a plain
130+
* scope list is acquired silently; set `createIfNone` to allow an interactive consent prompt when
131+
* no session for the requested scopes has been granted yet. Challenge requests always allow prompting.
129132
*
130133
* @returns A VS Code authentication session or undefined, if none could be obtained.
131134
*/
132-
getSessionWithScopes(scopeListOrRequest: string[] | vscode.AuthenticationWwwAuthenticateRequest): vscode.ProviderResult<vscode.AuthenticationSession>;
135+
getSessionWithScopes(scopeListOrRequest: string[] | vscode.AuthenticationWwwAuthenticateRequest, options?: GetSessionWithScopesOptions): vscode.ProviderResult<vscode.AuthenticationSession>;
133136
}
134137

135138
export declare interface AzureExtensionApi {
@@ -396,6 +399,17 @@ export declare function getAzExtResourceType(resource: {
396399
* */
397400
export declare function getAzureResourcesExtensionApi(extensionContext: vscode.ExtensionContext, apiVersionRange: '2.0.0', options?: GetApiOptions): Promise<AzureResourcesExtensionApi>;
398401

402+
/**
403+
* Options for {@link AzureAuthentication.getSessionWithScopes}.
404+
*/
405+
export declare interface GetSessionWithScopesOptions {
406+
/**
407+
* Whether to allow an interactive prompt (sign in / consent) if no session for the requested
408+
* scopes is already available. Defaults to `false`, in which case the session is acquired silently.
409+
*/
410+
createIfNone?: boolean;
411+
}
412+
399413
export declare function isWrapper(maybeWrapper: unknown): maybeWrapper is Wrapper;
400414

401415
/**

api/src/resources/azure.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,24 @@ export interface AzureAuthentication {
2424
*
2525
* @param scopeListOrRequest - The scopes for which the authentication is needed. Use AuthenticationWwwAuthenticateRequest for supporting challenge requests.
2626
* Note: use of AuthenticationWwwAuthenticateRequest requires VS Code v1.105.0
27+
* @param options - (Optional) Options controlling how the session is acquired. By default a plain
28+
* scope list is acquired silently; set `createIfNone` to allow an interactive consent prompt when
29+
* no session for the requested scopes has been granted yet. Challenge requests always allow prompting.
2730
*
2831
* @returns A VS Code authentication session or undefined, if none could be obtained.
2932
*/
30-
getSessionWithScopes(scopeListOrRequest: string[] | vscode.AuthenticationWwwAuthenticateRequest): vscode.ProviderResult<vscode.AuthenticationSession>;
33+
getSessionWithScopes(scopeListOrRequest: string[] | vscode.AuthenticationWwwAuthenticateRequest, options?: GetSessionWithScopesOptions): vscode.ProviderResult<vscode.AuthenticationSession>;
34+
}
35+
36+
/**
37+
* Options for {@link AzureAuthentication.getSessionWithScopes}.
38+
*/
39+
export interface GetSessionWithScopesOptions {
40+
/**
41+
* Whether to allow an interactive prompt (sign in / consent) if no session for the requested
42+
* scopes is already available. Defaults to `false`, in which case the session is acquired silently.
43+
*/
44+
createIfNone?: boolean;
3145
}
3246

3347
/**

0 commit comments

Comments
 (0)