Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 1x 3x 3x 3x 3x 3x | import * as vscode from 'vscode';
/**
* Service for handling Microsoft Entra ID authentication using VS Code's built-in authentication API.
*/
export class MicrosoftAuthService {
private static readonly PROVIDER_ID = 'microsoft';
/**
* Checks if there's an existing session without prompting the user.
* @param scopes The OAuth scopes to check.
* @returns A promise that resolves to the access token if a session exists, or undefined.
*/
async getSession(scopes: string[], createIfNone: boolean = false): Promise<vscode.AuthenticationSession | undefined> {
try {
const id = MicrosoftAuthService.PROVIDER_ID;
const options = { createIfNone: createIfNone };
const session = await vscode.authentication.getSession(id, scopes, options);
return session;
} catch {
return undefined;
}
}
} |