在设置身份Asp.Net的REDIRECT_URI [英] Setting the redirect_uri in Asp.Net Identity

查看:243
本文介绍了在设置身份Asp.Net的REDIRECT_URI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,以便为Asp.Net身份Facebook登录的REDIRECT_URI。然而,在对的AccountController REST GetExternalLogin方法仅触发如果REDIRECT_URI是'/'。如果我添加任何东西它不会触发GetExternalLogin,浏览器只显示*错误:INVALID_REQUEST *。

不过URL包含重定向的参数,因为它应该如如果我添加REDIRECT_URI为的http://本地主机:25432 /测试

响应URL看起来是这样的:

<$p$p><$c$c>http://localhost:25432/api/Account/ExternalLogin?provider=Facebook&response_type=token&client_id=self&redirect_uri=http%3A%2F%2Flocalhost%3A25432%2Ftesting&state=0NctHHGq_aiazEurHYbvJT8hDgl0GJ_GGSdFfq2z5SA1

和浏览器窗口显示:
错误:INVALID_REQUEST

任何想法,为什么重定向到'/'而不是任何其他url's当这仅适用?

谢谢!


解决方案

的问题是, GetExternalLogin 注册为 OAuthOptions.AuthorizeEndpointPath 其中用于 app.UseOAuthBearerTokens(OAuthOptions)。这种配置使验证端点上的参数。

 如果(!Uri.TryCreate(authorizeRequest.RedirectUri,UriKind.Absolute,出validatingUri))
{
    //重定向端点URI必须是绝对URI
}
否则,如果(!String.IsNullOrEmpty(validatingUri.Fragment))
{
    //端点URI不能包含一个片段组成部分。
}
否则,如果(Options.AllowInsecureHttp&安培;!&安培;
                    String.Equals(validatingUri.Scheme,Uri.UriSchemeHttp,StringComparison.OrdinalIgnoreCase))
{
    //重定向端点应要求使用TLS
}

和你应该通过授权端点的请求缺少必要的参数RESPONSE_TYPE和
授权端点请求包含不受支持RESPONSE_TYPE参数

I am trying to set the redirect_uri for the facebook login with Asp.Net Identity. However the GetExternalLogin REST method in the AccountController is only triggered if the redirect_uri is '/' . If I add anything else it does not trigger GetExternalLogin, the browser only shows *error: invalid_request*.

However the url contains the redirected parameter as it should e.g. if I add the redirect_uri as http://localhost:25432/testing

the response url looks like this:

http://localhost:25432/api/Account/ExternalLogin?provider=Facebook&response_type=token&client_id=self&redirect_uri=http%3A%2F%2Flocalhost%3A25432%2Ftesting&state=0NctHHGq_aiazEurHYbvJT8hDgl0GJ_GGSdFfq2z5SA1

and the browser window shows: error: invalid_request

Any idea why this works only when redirecting to '/' but not to any other url´s?

Thanks!

解决方案

The problem is that GetExternalLogin registered as OAuthOptions.AuthorizeEndpointPath which used for app.UseOAuthBearerTokens(OAuthOptions). This configuration puts validation on arguments of endpoint.

if (!Uri.TryCreate(authorizeRequest.RedirectUri, UriKind.Absolute, out validatingUri))
{
    // The redirection endpoint URI MUST be an absolute URI
}
else if (!String.IsNullOrEmpty(validatingUri.Fragment))
{
    // The endpoint URI MUST NOT include a fragment component.
}
else if (!Options.AllowInsecureHttp &&
                    String.Equals(validatingUri.Scheme, Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase))
{
    // The redirection endpoint SHOULD require the use of TLS
}

And you should pass "Authorize endpoint request missing required response_type parameter" and "Authorize endpoint request contains unsupported response_type parameter"

这篇关于在设置身份Asp.Net的REDIRECT_URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆