简体   繁体   English

asp.net mvc 5和oauth2登录

[英]asp.net mvc 5 and oauth2 login

I'm working on a asp.net mvc 5 project that will use the meetup.com oauth2 api to login. 我正在一个asp.net mvc 5项目上,该项目将使用Meetup.com oauth2 api登录。 Unfortunately, I'm having an issue where my webapp successfully redirects to the meetup login page and I can hit "allow", but then it will stop because the AuthenticationHandler detects the properties of the "state" field as null and nothing shows up on the page. 不幸的是,我遇到一个问题,其中我的Web应用程序成功重定向到metup登录页面,我可以点击“允许”,但随后它将停止,因为AuthenticationHandler将“ state”字段的属性检测为null,并且在这一页。 I'm using passive AuthenticationMode and afaik meetup.com API doesn't use "state" field, so I'm not sure how to prevent the AuthenticationHandler from returning null and stopping in the middle because it thinks there's an error when there isn't a "state" to begin with. 我正在使用被动AuthenticationMode,而afaik metup.com API不使用“状态”字段,因此我不确定如何防止AuthenticationHandler返回null并在中间停止,因为它认为当存在错误时,首先是“状态”。 Here is the relevant code: 以下是相关代码:

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
            }

found a pre-existing open source library that works 找到了一个可以正常工作的开源库

https://github.com/KatanaContrib/KatanaContrib.Security.Meetup https://github.com/KatanaContrib/KatanaContrib.Security.Meetup

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM