IdentityServer4.Validation.AuthorizeRequestValidator [0]“ redirect_uri丢失或太长”

时间:2019-06-25 10:56:53

标签: identityserver4

我正在使用IdentityServer4和asp.netcore 2.2设置安全服务器。我想使用Azure AD进行身份验证,并使用Asp.Net IdentityCore保留我的用户数据。我已经使用AddMicrosoftAccount设置了外部身份验证。身份验证有效,但是我总是收到“ IdentityServer4.Validation.AuthorizeRequestValidator [0] redirect_uri丢失或太长”的提示。我已经调试了代码,并注意到返回URL已正确地在查询字符串中传递给Login.cshtml.cs。 OnGetAsync方法的returnUrl参数却没有返回URL。它看起来像被剥离到某个地方。请帮助

我正在使用IdentityServer4,用于配置和操作数据的SQL Server,使用Asp.NetCoreIdentity的用于用户数据的Sql服务器。我已经创建了一个mvc客户端并将其注册到服务器。我已经向客户端应用程序的Home控制器添加了一个authorize属性,以触发身份验证。

rleid(x$DATE)

我希望安全服务器在成功认证之后能够重定向回我的客户端Home Controller方法。相反,我收到上述错误。 我想念什么

1 个答案:

答案 0 :(得分:0)

您尚未在客户端的配置中配置任何RedirectUris。您需要添加至少一个重定向uri。

RedirectUris = {"http://<your redirect uri>"}

例如:

var webClient = new IdentityServer4.EntityFramework.Entities.Client
{
    ClientId = "mvc",
    ClientName = "MVC Client",
    Description = "Test MVC Client",
    RequireConsent = false,
    AlwaysIncludeUserClaimsInIdToken = true,
    RedirectUris = {"http://<your redirect uri>"}
    AllowedScopes = new List<ClientScope>
    {
        new ClientScope
        {                       
            Scope = IdentityServerConstants.StandardScopes.OpenId 
        },
        new ClientScope
        {
            Scope = IdentityServerConstants.StandardScopes.Profile
        }
    }
};