Identityserver4 无效的重定向uri,即使它们相同

Identityserver4 无效的重定向uri,即使它们相同,identityserver4,Identityserver4,当尝试登录到identityserver(使用.net core 3预览版)时,即使请求uri和允许的uri相同,我也会收到无效的重定向uri错误 我还能做错什么 失败:IdentityServer4.Validation.AuthorizationRequestValidator[0] 无效的重定向uri:http://localhost:1337/authentication/login-回拨 { “客户端ID”:“myapp”, “客户端名称”:“myapp”, “允许重定向URI”:[

当尝试登录到identityserver(使用.net core 3预览版)时,即使请求uri和允许的uri相同,我也会收到无效的重定向uri错误

我还能做错什么

失败:IdentityServer4.Validation.AuthorizationRequestValidator[0]
无效的重定向uri:http://localhost:1337/authentication/login-回拨
{
“客户端ID”:“myapp”,
“客户端名称”:“myapp”,
“允许重定向URI”:[
"http://localhost:1337/authentication/login-“回调”
],
“主体”:“匿名”,
“RequestedScopes”:“”,
“原始”:{
“客户端id”:“myapp”,
“重定向uri”:http://localhost:1337/authentication/login-回拨“,
“响应类型”:“标识令牌”,
“范围”:“webAPI openid配置文件”,
“状态”:“5a10fc5a7006475c8d3a348c711ca58a”,
“暂时性”:“ae6f9f35837241e1ba3841c2ff8a4fce”,
“提示”:“无”
}
}
失败:IdentityServer4.Endpoints.AuthorizeEndpoint[0]
请求验证失败

我在core 3的新identity server功能中使用了错误的配置文件。正在使用“IdentitySpa”-应该是“SPA”


我想为需要更深入解释的人补充一点,这对
IdentityServerSPA
客户端类型不起作用的原因是,当您调用
AddApiAuthorization
时:

services.AddIdentityServer()
.ADDAPI授权行65执行以下操作:

builder.addAsNetIdentity()
.addstore()
.ConfigureReplacedServices()//
client.Properties.TryGetValue(ApplicationProfilesPropertyNames.Profile,out var clientType)&&
ApplicationProfiles.IdentityServerSPA==clientType;

我添加这个答案既是为了帮助他人,也是为了帮助自己更好地理解这一点:)

这可能不是同一个问题(我远不是这里的专家)。但我确实遇到了同样的问题,这让我找到了这篇文章

我发现在我的例子中,问题是返回url上缺少尾随/字符。这个github问题触发了我:。看看JefSchraag在2020年5月1日发表的评论

我的客户机项目中RedirectToLogin.razor组件中的这一修改似乎解决了这个问题

protected override void OnInitialized()
{
    var returnUrl = Navigation.Uri;

    if (!returnUrl.EndsWith('/'))
    {
        returnUrl += '/';
    }

    Navigation.NavigateTo($"authentication/login?returnUrl={returnUrl}");
}

你能让我们知道你正在使用的完整url是什么吗,(连接/授权)该死的我也:|缺失/结尾处