Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

WebApi oauth from latest template not completing processing after successful login

$
0
0

Using the latest Visual Studio WebApi template with Individual accounts enabled I have configured 3 external providers - twitter, facebook & google for oauth authenticaton.
All three are getting to the stage where they authenticate with the 3rd party provider and are redirected to the correct url which causes the following code to execute -

ApplicationUser user = await UserManager.FindAsync(new UserLoginInfo(externalLogin.LoginProvider,
            externalLogin.ProviderKey));

        bool hasRegistered = user != null;

        if (hasRegistered)
        {
            Authentication.SignOut(DefaultAuthenticationTypes.ExternalCookie);

            ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(UserManager,
               OAuthDefaults.AuthenticationType);
            ClaimsIdentity cookieIdentity = await user.GenerateUserIdentityAsync(UserManager,
                CookieAuthenticationDefaults.AuthenticationType);

            AuthenticationProperties properties = ApplicationOAuthProvider.CreateProperties(user.UserName);
            Authentication.SignIn(properties, oAuthIdentity, cookieIdentity);
        }
        else
        {
      // this code is executed
            IEnumerable<Claim> claims = externalLogin.GetClaims();
            ClaimsIdentity identity = new ClaimsIdentity(claims, OAuthDefaults.AuthenticationType);
            Authentication.SignIn(identity);
        }

        return Ok();

After completing this code the user is redirected to the url below and processing stops.

https://localhost:44301/#access_token=Qw5g_ZlGV1

I have watched the video https://channel9.msdn.com/Shows/Web+Camps+TV/Securing-ASPNET-Web-APIs (33 mins 20 secs) which shows that the next step is missing - a redirect to the register page where the user is able to configure & register themselves.

Does anyone know what is missing here?

Thanks


Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>