在 AAD 应用程序注册中,隐式授予流程为 true;我们已将权限委派给 User.Read 和 User.Read.All。
private static getContext(): Msal.UserAgentApplication {
if (AuthenticationService.Context) return AuthenticationService.Context;
const logger = new Msal.Logger((_logLevel, message, _piiEnabled) => {
console.log(message);
}, { level: Msal.LogLevel.Verbose, correlationId: "12345" });
AuthenticationService.Context = new Msal.UserAgentApplication(
Environment().authentication.clientId,
AuthenticationService.getAuthority(),
(errorDesc, token, error, _tokenType) => {
if (token) {
AuthenticationService.isAuthenticated = true;
AuthenticationService.accessToken = token;
} else {
const localizedError: string = LocalizationService.localize(error);
alert(localizedError !== error ? localizedError : errorDesc);
}
},
{
logger: logger,
storeAuthStateInCookie: true,
state: "12345",
cacheLocation: "localStorage" …Run Code Online (Sandbox Code Playgroud)