2017-03-09 80 views
2

只有当外部登录缺失或过于long`我得到:`REDIRECT_URI使用外部登录

fail: IdentityServer4.Validation.AuthorizeRequestValidator[0] 
     redirect_uri is missing or too long 

redirect_uri在客户端配置为“http://localhost:1234/signin-callback”,但在登录时我没有得到这个错误与密码。

[HttpGet] 
    public IActionResult ExternalLogin(string provider, string returnUrl = null) 
    { 
     var redirectUrl = Url.Action("ExternalLoginCallback", "Controller", new { ReturnUrl = returnUrl }); 
     var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl); 
     return Challenge(properties, provider); 
    } 

    [HttpGet] 
    public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null) 
    { 
     if (remoteError != null) 
     { 
      return BadRequest(remoteError); 
     } 
     var info = await _signInManager.GetExternalLoginInfoAsync(); 
     if (info == null) 
     { 
      return BadRequest("no login info"); 
     } 
     var result = await _signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey, isPersistent: false); 
     if (result.Succeeded) 
     { 
      return Redirect(returnUrl); // debug gets to here where we redirect to "/connect/authorize/login?client_id=my-client" 
     } 
     return BadRequest(); 
    } 

此代码成功签署在但是当它重定向到“/连接/授权/登录?CLIENT_ID =我的客户”则返回错误。我应该寻找什么?

回答

1

我太快发表一个问题。

它需要重定向到/connect/authorize/login?client_id=my-client&redirect_uri=http://localhost:1234/signin-callback而不仅仅是/connect/authorize/login?client_id=my-client

当我需要/ExternalLogin?provider=[provider]&returnUrl=[encoded url]时,我正在通过ExternalLogin()/ExternalLogin?provider=[provider]&returnUrl=[plain text url with escaping '&']