【发布时间】:2020-05-01 02:15:11
【问题描述】:
我有一个配置了 OpenIdConnect 到 Azure AD 的 Identity Server 4。
当用户单击登录按钮时,IS4 重定向到 Azure AD,并在回调到 IS4 时显示此错误:
这是我向邮递员请求令牌的方式:
注意回调url是移动应用格式。
这是我的配置:
services.AddAuthentication()
.AddCookie(options => new CookieAuthenticationOptions
{
ExpireTimeSpan = TimeSpan.FromHours(12),
SlidingExpiration = false,
Cookie = new CookieBuilder
{
Path = "",
Name = "MyCookie"
}
}).AddOpenIdConnect(options =>
{
options.ClientId = configuration["OpenIdConnect:ClientId"];
options.Authority = configuration["OpenIdConnect:Authority"];
options.SignedOutRedirectUri = configuration["OpenIdConnect:PostLogoutRedirectUri"];
options.CallbackPath = configuration["OpenIdConnect:CallbackPath"];
options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
options.Resource = configuration["OpenIdConnect:Resource"];
options.ClientSecret = configuration["OpenIdConnect:ClientSecret"];
options.SaveTokens = true;
options.RequireHttpsMetadata = false;
options.TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name",
RoleClaimType = "role"
};
options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
});
这是我的参数:
"OpenIdConnect": {
"ClientId": "xxxxxxxxxx",
"Authority": "https://login.microsoftonline.com/xxxxxxxxxx/",
"PostLogoutRedirectUri": "https://uri-of-my-identity-server.azurewebsites.net",
"CallbackPath": "/signin-oidc",
"ResponseType": "code id_token",
"Resource": "https://graph.microsoft.com/",
"ClientSecret": "my-secret"
},
注意:此错误仅发生在 Azure 环境(不是本地)
注意:在 Xamarin 应用程序上,当 Azure 返回 IS4 同意屏幕时,它会显示以下消息:
【问题讨论】:
-
您可以尝试将CallbackPath更改为
/signin-oidc-aad,并将AAD应用重定向url修改为https://uri-of-my-identity-server.azurewebsites.net/signin-oidc-aad -
@NanYu 我在我的 IS4 参数和 Azure AD 配置上配置了新的 url(带有 -aad 字符串)但我得到了同样的错误
-
AuthenticationController 回调的代码在哪里
标签: .net-core oauth-2.0 identityserver4