[英]Fetching oauth credentials after asp.net mvc Twitter OAuth2 login
[英]asp.net mvc 5 and oauth2 login
我正在一个asp.net mvc 5项目上,该项目将使用Meetup.com oauth2 api登录。 不幸的是,我遇到一个问题,其中我的Web应用程序成功重定向到metup登录页面,我可以点击“允许”,但随后它将停止,因为AuthenticationHandler将“ state”字段的属性检测为null,并且在这一页。 我正在使用被动AuthenticationMode,而afaik metup.com API不使用“状态”字段,因此我不确定如何防止AuthenticationHandler返回null并在中间停止,因为它认为当存在错误时,首先是“状态”。 以下是相关代码:
protected override async Task<AuthenticationTicket> AuthenticateCoreAsync()
{
AuthenticationProperties properties = null;
try
{
string code = null;
string state = null;
IReadableStringCollection query = Request.Query;
IList<string> values = query.GetValues("code");
if (values != null && values.Count == 1)
{
code = values[0];
}
values = query.GetValues("state");
if (values != null && values.Count == 1)
{
state = values[0];
}
properties = Options.StateDataFormat.Unprotect(state);
if (properties == null)
{
return null; // the error here
}
找到了一个可以正常工作的开源库
https://github.com/KatanaContrib/KatanaContrib.Security.Meetup
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.