Azure MSAL-身份验证无法实现userinfo请求

问题描述 投票:0回答:1

我已经使用Implicit Flow在我的角度应用程序中实现了msal库。我可以使用Microsoft广告帐户登录,并且拥有api使用身份验证请求所需的令牌。当我使用https://jwt.ms/解码令牌时,我可以看到aud密钥的值是我的[[client app id,它的用户信息网址应该看起来像什么?如果我将使用文档中描述的这些端点,则我将使用无效令牌出错:https://graph.microsoft.com/oidc/userinfohttps://graph.microsoft.com/v1.0/me/

{ "error": { "code": "InvalidAuthenticationToken", "message": "Access token validation failure. Invalid audience.", "innerError": { "request-id": "8177b64f-c899-48c3-aceb-xxxxxxxxx", "date": "2020-03-18T07:41:04" } }
}
azure authentication active-directory openid msal
1个回答
0
投票
如果要调用Microsoft Graph API,则需要获取具有正确的(Microsoft graph api)受众的访问令牌。

获取访问令牌时,应使用https://graph.microsoft.com/User.Read或仅使用User.Read作为范围。

此外,请记住在Azure门户上为您的应用程序添加User.Read权限。应用程序注册->您的应用程序-> API权限->添加权限->选择Microsoft Graph API->委托权限->检查所需的权限。

参考:

MSAL Angular to login, logout, protect a route, and acquire an access token for Microsoft Graph.

© www.soinside.com 2019 - 2024. All rights reserved.