aspnet / AspNetKatana

Microsoft's OWIN implementation, the Katana project
Apache License 2.0
959 stars 331 forks source link

GetExternalLoginInfoAsync() return null for facebook only #504

Closed Pom-Veerawat closed 7 months ago

Pom-Veerawat commented 1 year ago

Previously, I facing the same problem, I upgraded to version 3.0.1 and it is working. Now I have the same problem again and try to upgrade with nuget to version 4.2.2 but this time it is not working. I got error=accesse_denied in url, and return null in GetExternalLoginInfoAsync(). google is working, just only facebook return null

        Startup.Auth.cs
         var facebookOptions = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationOptions()
        {
            AppId = "xx",
            AppSecret = "xx",
            CookieManager = new Microsoft.Owin.Host.SystemWeb.SystemWebCookieManager()
        };

        app.UseFacebookAuthentication(facebookOptions);

        AccountController.cs
         public ActionResult ExternalLogin(string provider, string returnUrl)
          {

              ControllerContext.HttpContext.Session.RemoveAll(); //this is for swap facebook and google

              // Request a redirect to the external login provider
              return new ChallengeResult(provider, Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl }));
          }

           [AllowAnonymous]
          public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
          {
              if(returnUrl == null)
              {
                  returnUrl = "";
              }               

              var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
              if (loginInfo == null) // this always return null
              {
              .
              .
              }
         }
Tratcher commented 1 year ago

error=accesse_denied sounds like it came from facebook's site, double check your appid and secret. Also, did you get any errors in the browser from facebook?

Pom-Veerawat commented 1 year ago

error=accesse_denied sounds like it came from facebook's site, double check your appid and secret. Also, did you get any errors in the browser from facebook?

no just only error=accesse_denied. I have double check both appid and secret. It is correct.

*edit attach link /Account/ExternalLoginCallback?error=accessdenied#=_

*request url to facebook before login

https://www.facebook.com/login.php?skip_api_login=1&api_key=27422591314xxxx&kid_directed_site=0&app_id=27422591314xxxx&signed_next=1&next=https%3A%2F%2Fwww.facebook.com%2Fv10.0%2Fdialog%2Foauth%3Fresponse_type%3Dcode%26client_id%3D27422591314xxxx%26redirect_uri%3Dhttps%253A%252F%252Fcadthai.com%252Fsignin-facebook%26scope%3Dpublic_profile%252Cemail%26state%3DFxRnQ-P7D59xbNcuqP0Dv_xiYcxFYXVUeZk24t9pUIoP_R6NGvy86u1kPY31JD3lSsUXafvetVB8pFLj-Imhl3wTDsCBImPmCdFQfIYA3CbyMJSjMOagdj8hWM3aLgwPW0dBPH-_tYWlaUGAgG-Zfn3blB5fwy-_1jVjUur73jZswQx-7VEMFDUVfVd9x-gz2wxJHGyEPxHaHmBIQchuJyd2hO8mVNsy7bf8hZYdwEAHMToS%26ret%3Dlogin%26fbapp_pres%3D0%26logger_id%3D88dbc8f8-5154-4d6c-9a0c-ab8d8c17d077%26tp%3Dunspecified&cancel_url=https%3A%2F%2Fcadthai.com%2Fsignin-facebook%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied%26state%3DFxRnQ-P7D59xbNcuqP0Dv_xiYcxFYXVUeZk24t9pUIoP_R6NGvy86u1kPY31JD3lSsUXafvetVB8pFLj-Imhl3wTDsCBImPmCdFQfIYA3CbyMJSjMOagdj8hWM3aLgwPW0dBPH-_tYWlaUGAgG-Zfn3blB5fwy-_1jVjUur73jZswQx-7VEMFDUVfVd9x-gz2wxJHGyEPxHaHmBIQchuJyd2hO8mVNsy7bf8hZYdwEAHMToS%23_%3D_&display=page&locale=th_TH&pl_dbl=0

Tratcher commented 1 year ago

cancel_url=https%3A%2F%2Fcadthai.com%2Fsignin-facebook%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied%26state%3DFxRnQ-P7D59xbNcuqP0Dv_xiYcxFYXVUeZk24t9pUIoP_R6NGvy86u1kPY31JD3lSsUXafvetVB8pFLj-Imhl3wTDsCBImPmCdFQfIYA3CbyMJSjMOagdj8hWM3aLgwPW0dBPH-_tYWlaUGAgG-Zfn3blB5fwy-1jVjUur73jZswQx-7VEMFDUVfVd9x-gz2wxJHGyEPxHaHmBIQchuJyd2hO8mVNsy7bf8hZYdwEAHMToS%23%3D_&display=page&locale=th_TH&pl_dbl=0

user_denied implies the user is declining to log in, or is declining some of the permissions you've requested.

Pom-Veerawat commented 1 year ago

it is url to facebook, I inspect another project they are having this url but they can log in

Pom-Veerawat commented 1 year ago

I think it is from facebook side, it is working lastweek and today is not working. Sending them ticket ut no response

kaihsinchang commented 12 months ago

i have similar problem. Do you have a solution please?