【问题标题】:Ignore multi-factor authentication in azure graph API request忽略 azure graph API 请求中的多因素身份验证
【发布时间】: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


【解决方案1】:

验证用户凭据的正确方法是让用户通过浏览器以交互方式进行身份验证。 这将允许他们通过 MFA、通过与 ADFS 的联合登录等。 最重要的是,用户不必向您的应用提供密码。

您尝试使用的流程仅存在于规范中,作为旧版应用程序的升级路径。 一旦启用 MFA,它的使用基本上就变得不可能了。

【讨论】:

    猜你喜欢
    • 2011-01-23
    • 2018-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-31
    相关资源
    最近更新 更多