我什么时候应该 select openid 或 email 作为范围 msal.js 在浏览器中执行

When should I select openid or email as scope in msal.js executin in browser

我有一个完全客户端的网页,可以 ajax 调用 Microsft ASP.NET 核心客户端 REST 服务。此 UI 应用程序和 Web 服务都在 Azure ActiveDirectory 租户中注册。我已成功使用在目录中注册的另一个 ASP.NET 核心应用程序进行用户身份验证,然后为 Web 服务请求 JWT 令牌并对其进行身份验证。 ASP.NET 核心身份验证代码无处可去,我必须在任何地方指定范围。如果我想调用图表 API,我请求了 https://graph.windows.net 的令牌并使用了它。

查看我在 AD 中创建的 this sample,似乎有必要为 'user.read' 请求令牌。但是,其他示例仅使用 ['openid']['openid', 'email']?

我知道 user.read 是 AzureAd 的权限,可以使用图表 api 读取我的整个用户配置文件。这是否意味着 openid 和电子邮件给我?

openidemail 范围在 Azure AD v2 应用程序中用于访问不同的信息。 v1 应用程序不需要它们。

引用自documentation

If an app performs sign-in by using OpenID Connect, it must request the openid scope. The openid scope shows on the work account consent page as the "Sign you in" permission, and on the personal Microsoft account consent page as the "View your profile and connect to apps and services using your Microsoft account" permission. With this permission, an app can receive a unique identifier for the user in the form of the sub claim. It also gives the app access to the UserInfo endpoint.

关于电子邮件范围:

The email scope can be used with the openid scope and any others. It gives the app access to the user's primary email address in the form of the email claim.

User.Read 是 Microsoft Graph API 的范围。实际上完全限定的形式是 https://graph.microsoft.com/User.Read。但是 MS Graph API 是一个特例 :)