我在IdentityServer4主机端配置了以下客户端:

new Client
{
     ClientId = "myClient",
     ....
     RedirectUris = {"https://localhost:44001/home/claims", 
                      "https://localhost:44001/"}
     ....
}

我目前正试图让它以这样一种方式返回,无论它来自哪个客户端应用程序中的控制器,它都能正常工作(因为redirectURI是在客户端应用程序的启动时配置的,必须与服务器的客户端配置相匹配) .

在客户端应用启动中,相关代码:

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
     ...
     ClientId = "myClient",
     RedirectUri = "https://localhost:44001/",
     ...
}

当我将redirectUri设置为上面的第二个选项,“https://localhost:44001”在客户端启动时,我被重定向到客户端错误控制器,并出现以下错误:

“抱歉,有一个错误:unauthorized_client无效redirect_uri” .

此外,服务器向控制台输出以下错误:

抛出异常:System.Private.CoreLib.dll中的'System.FormatException'IdentityServer4.Validation.AuthorizeRequestValidator:错误:无效的redirect_uri:https:// localhost:44001 / {“ClientId”:“myClient”,...“AllowedRedirectUris “:[”https:// localhost:44001 / home / claims“,”https:// localhost:44001 /“],”SubjectId“:”anonymous“,”RequestedScopes“:”“,”Raw“:{” client_id“:”myClient“,”redirect_uri“:”https:// localhost:44001 /“,”response_mode“:”form_post“,”response_type“:”code id_token“,...}}

这几乎就像你不能为客户端提供多个重定向URI,但这可能不对 .