Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为来宾获取Azure广告令牌_C#_Asp.net Mvc_Azure_Azure Active Directory - Fatal编程技术网

C# 为来宾获取Azure广告令牌

C# 为来宾获取Azure广告令牌,c#,asp.net-mvc,azure,azure-active-directory,C#,Asp.net Mvc,Azure,Azure Active Directory,在Azure上注册的Web API应用程序中,我通过以下方式为Active Directory中的用户获取令牌: var result = await client.PostAsync(oauthEndpoint, new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("client_id", _azureOptions.ClientId), new Key

在Azure上注册的Web API应用程序中,我通过以下方式为Active Directory中的用户获取令牌:

    var result = await client.PostAsync(oauthEndpoint, new FormUrlEncodedContent(new[]
    {
        new KeyValuePair<string, string>("client_id", _azureOptions.ClientId),
        new KeyValuePair<string, string>("grant_type", "password"),
        new KeyValuePair<string, string>("username", userName),
        new KeyValuePair<string, string>("password", password),
        new KeyValuePair<string, string>("client_secret", _azureOptions.ClientSecret),
        new KeyValuePair<string, string>("client_info", "1"),
        new KeyValuePair<string, string>("scope",
                                    "openid offline_access profile api://xxxxxxx-xxxxxxxxx-xxxxxxxxxxx/access_as_user"),
                            })).ConfigureAwait(false);
...
var result=wait client.PostAsync(oauthEndpoint,新表单URLEncodedContent(新[]
{
新的KeyValuePair(“客户机id”,“azureOptions.ClientId”),
新的KeyValuePair(“授权类型”、“密码”),
新的KeyValuePair(“用户名”,用户名),
新的KeyValuePair(“密码”,password),
新的KeyValuePair(“客户机密码”,“azureOptions.ClientSecret”),
新的KeyValuePair(“客户端信息”,“1”),
新的KeyValuePair(“范围”,
“openid脱机访问配置文件”api://xxxxxxx-xxxxxxxxx-xxxxxxxxxxx/access_as_user"),
})).配置等待(错误);
...
我工作得很好。 我添加了一个gmail.com访客帐户,现在我得到了一个错误

{“error”:“invalid_grant”,“error_description”:“AADSTS50034:用户” 中不存在帐户Microsoft.AzureAD.Telemetry.Diagnostics.PII gmail.com目录。要登录此应用程序,请 必须添加到目录中。\r\n空间ID: c0a3f945-d446-430c-8e4e-fd77c95a5500\r\n相关ID: 6cd071f3-b5b0-4ed2-98a2-292f45863e1a\r\n时间戳:2019-04-26 12:31:28Z,“错误代码”:[50034],“时间戳”:“2019-04-26” 12:31:28Z,“跟踪id”:“c0a3f945-d446-430c-8e4e-fd77c95a5500”,“相关性id”:“6cd071f3-b5b0-4ed2-98a2-292f45863e1a”}

我怎样才能解决这个问题?如果我使用azure Authentication创建基本ASP.NET MVC核心应用程序,该应用程序将重定向到microsoft页面,那么基本应用程序将与guest一起工作


但是在我的“静默身份验证”案例中,来宾用户不工作

您不能对来宾使用ROPC流(您在这里使用的)。 它不适用于联邦帐户。 它也不适用于具有MFA或过期密码的用户。
我通常建议人们远离此流程。

您能给我一个关于描述此限制的文档链接吗?其中一些在这里,谢谢。我相信被邀请到Azure广告租户的在线个人帐户不能使用ROPC。答案是什么