【发布时间】:2019-09-15 23:33:42
【问题描述】:
在我在 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);
...
而且我工作得很好。 我添加了一个 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","error_codes":[50034],"timestamp":"2019-04-26 12:31:28Z","trace_id":"c0a3f945-d446-430c-8e4e-fd77c95a5500","correlation_id":"6cd071f3-b5b0-4ed2-98a2-292f45863e1a"}
我该如何解决这个问题?如果我使用 azure authentiacation 创建基本的 ASP.NET MVC Core 应用程序,该应用程序重定向到 microsoft 页面,则基本应用程序可以与来宾一起使用。
但在我的“静默身份验证”情况下,访客用户不起作用
【问题讨论】:
标签: c# asp.net-mvc azure azure-active-directory