我正在开发一个带有react前端和.NET核心3.1后端的web应用程序,并被要求添加Azure单点登录功能。我正在使用react库(https://www.npmjs.com/package/react-aad-msal)。我调用MsalAuthProvider.getAccessToken()并得到这个错误:
Can't construct an AccessTokenResponse from a AuthResponse that has a token type of "id_token".
有谁可以帮我?
有没有人?顺便说一句。getAccessToken()实际上在标准的msal库中,如果这有帮助的话。
发布于 2020-10-08 12:38:11
通过进入packages.json并降低“依赖项”中"msal“的版本号,我自己找到了一个解决方案,如下所示:
"msal": "~1.3.0",
发布于 2020-10-23 21:52:59
更改authProvider中的作用域。
export const authProvider = new MsalAuthProvider(
{
auth: {
authority: 'https://login.microsoftonline.com/5555555-5555-5555-5555-555555555555',
clientId: 'AAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA',
postLogoutRedirectUri: 'http://localhost:3000/signin',
redirectUri: 'http://localhost:3000/signin',
validateAuthority: true,
navigateToLoginRequestUrl: false
},
system: {
logger: new Logger(
(logLevel, message, containsPii) => {
console.log("[MSAL]", message);
},
{
level: LogLevel.Verbose,
piiLoggingEnabled: false
}
)
},
cache: {
cacheLocation: "sessionStorage",
storeAuthStateInCookie: true
}
},
{
scopes: ["openid", "profile", "user.read"] // <<<-----------|
},
{
loginType: LoginType.Popup,
tokenRefreshUri: window.location.origin + "/auth.html"
}
);https://stackoverflow.com/questions/64244668
复制相似问题