Why MVC 5 Owin Oauth is not hitting /Account/ExternalLoginCallback action

前端 未结 5 476
孤街浪徒
孤街浪徒 2021-01-12 08:31

I am new to MVC 5 authentication. Currently I tried Google Authorization using Owin The code in startup.Auth.cs

var googleOAuth2Authenticati         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-12 09:29

    This is similar to: Google Authentication using OWIN Oauth in MVC5 not hitting ExternalLoginCallback function

    Basically, set your google App in the Developers dashboard to point to your */ExternalLoginCallback method.

    Leave the GoogleProvider with the default callback path.

    var googleOAuth2AuthenticationOptions = new GoogleOAuth2AuthenticationOptions
        {
            ClientId = "MYCLIENTID",
            ClientSecret = "MYSECRET"
        };
    

    Add a route to handle signin-google in RouteConfig:

    routes.MapRoute(
                name: "signin-google",
                url: "signin-google",
                defaults: new { controller = "[YOURCONTROLLLER]", action = "ExternalLoginCallback"});
    

    That should fix google provider and all the others too.

提交回复
热议问题