【发布时间】:2020-04-09 15:31:20
【问题描述】:
我想验证来自 Azure AD 的用户凭据。它适用于尚未启用 MFA 的用户。但启用 MFA 的用户遇到错误。
由于您的管理员进行了配置更改,或者因为 您搬到了一个新位置,您必须使用多因素身份验证 访问
因此,当我们通过图形 API 访问时,它需要一种忽略 MFA 的方法
这是我的代码。
var values = new Dictionary<string, string>
{
{ "grant_type", "password" },
{ "client_secret", appKey },
{ "client_id", clientId },
{ "username", userName },
{ "password", password },
{ "scope", "User.Read openid profile offline_access" },
};
HttpClient client = new HttpClient();
string requestUrl = $"https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token";
var content = new FormUrlEncodedContent(values);
var response = client.PostAsync(requestUrl, content).Result;
if (response.IsSuccessStatusCode)
{
return true;
}
else
{
return false;
}
【问题讨论】:
-
是的,MFA 不支持您尝试的授权类型,这就是启用 MFA 的用户收到该错误的原因。
标签: azure-active-directory azure-ad-graph-api multi-factor-authentication