根据文档,Microsoft Graph 仅支持来自 Azure AD v2.0 和 Azure AD 的令牌:
Microsoft Graph 支持两种身份验证提供程序:
- 要使用个人 Microsoft 帐户(例如 live.com 或 outlook.com 帐户)对用户进行身份验证,请使用 Azure Active Directory (Azure AD) v2.0 终结点。
- 若要使用企业(即工作或学校)帐户对用户进行身份验证,请使用 Azure AD。
但是,Azure AD v2.0 是支持两种 Microsoft 帐户类型的新端点:个人(以前的 Live 帐户)和工作/学校(经典的 Azure AD 帐户)。目前还不清楚,如何将授权仅限于个人帐户。
Azure AD 仅支持工作/学校帐户。
那么,如果我想允许我的应用程序仅使用个人帐户,该怎么做?如何仅使用 Microsoft 个人帐户在 Microsoft Graph 中进行身份验证(禁止用户使用工作/学校帐户)?
PS:如果重要的话,我在我的应用程序中使用 MSAL 进行身份验证。
根据 的文档Azure AD v2.0
,如果您只想支持Microsoft Accounts
,您想要使用的端点是https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize
. 这里的关键是consumers
确保您的用户只能选择使用 Microsoft 帐户进行身份验证。
如果我接受Github example of MSAL
,你会做出的改变是Startup_Auth.cs
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
// The `Authority` represents the v2.0 endpoint - https://login.microsoftonline.com/consumers/v2.0
// The `Scope` describes the initial permissions that your app will need. See https://azure.microsoft.com/documentation/articles/active-directory-v2-scopes/
ClientId = clientId,
Authority = String.Format(CultureInfo.InvariantCulture, aadInstance, "consumers", "/v2.0"),
RedirectUri = redirectUri,
Scope = "openid email profile offline_access Mail.Read",
PostLogoutRedirectUri = redirectUri,
TokenValidationParameters = new TokenValidationParameters
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句