簡體   English   中英

asp.net mvc 5和oauth2登錄

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM