Why MVC 5 Owin Oauth is not hitting /Account/ExternalLoginCallback action
asp.net-mvc-5, oauth
Solution
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.
Problem
I am new to MVC 5 authentication. Currently I tried Google Authorization using Owin The code in startup.Auth.cs ``` var googleOAuth2AuthenticationOptions = new GoogleOAuth2AuthenticationOptions { ClientId = "Client-id", ClientSecret = "secret-key", CallbackPath = new PathString("/Account/ExternalLoginCallback"), Provider = new GoogleOAuth2AuthenticationProvider() { OnAuthenticated = async context => { context.Identity.AddClaim(new Claim("picture", context.User.GetValue("picture").ToString())); context.Identity.AddClaim(new Claim("profile", context.User.GetValue("profile").ToString())); } } }; googleOAuth2AuthenticationOptions.Scope.Add("email"); app.UseGoogleAuthentication(googleOAuth2AuthenticationOptions); ``` But it does not hit ExternalLoginCallback Action for debug. ``` [AllowAnonymous] public async Task<ActionResult> ExternalLoginCallback(string returnUrl) ``` It stop at /Account/ExternalLoginCallback?ReturnUrl=%2F with blank white screen. I won't find what is wrong with this. and find similar question Google Authentication using OWIN Oauth in MVC5 not hitting ExternalLoginCallback function, but it is not helpful in mine case.