如何获取 Azure AD OAuth 登录的登录用户配置文件?配置文件、用户、Azure、AD

2023-09-06 17:21:02 作者:旋律,风一样的飘过

从 用于 Azure AD v2 登录的 JavaScript OAuth2 流程没有提供 access_token,我正在尝试找出要使用的最佳端点,以获取登录用户的详细信息(例如,显示名称、电子邮件、等等).

Following on from JavaScript OAuth2 flow for Azure AD v2 login does not give an access_token, I'm trying to figure out the best endpoint to use, to get the logged in users details (eg, display name, email, etc.).

但是,我注意到我可以使用 2 个潜在的端点

However, I noticed in there are 2 potential endpoints I can use

https://outlook.office.com/api/v2.0/mehttps://graph.microsoft.com/v1.0/me

1,用于 bell forhapijs 并记录在 使用Outlook REST API.但是,在贝尔,我似乎无法弄清楚我需要让它为 OAuth 2.0 工作的 scope.我已经尝试过 openidemailprofileMail.Read(只是因为我见过它在一些文档中)和 User.Read,但前 3 个作用域不会按照 用于 Azure AD v2 登录的 JavaScript OAuth2 流不提供 access_token,最后 2 个(Mail.ReadUser.Read)给了我一个 access_token,但他们给了我身份验证调用 https://outlook.office.com/api/v2.0/me 时出现问题 with Authorization: 'Bearer [access_token].

1, is used in bell for hapijs and is documented in Use the Outlook REST API. However, in bell, I can't seem to figure out the scope I need to get it working for OAuth 2.0. I've tried openid, email, profile, Mail.Read (only trying this because I've seen it in some docs), and User.Read, but the first 3 scopes don't give back a access_token as per JavaScript OAuth2 flow for Azure AD v2 login does not give an access_token, and the last 2 (Mail.Read, and User.Read) give me an access_token, but they give me authentication issues when calling https://outlook.office.com/api/v2.0/me with Authorization: 'Bearer [access_token].

我在