User-1204646426 posted
Hello, I am developing an ASP.NET MVC 5 Web application that allows user to authenticate using an external provider and .NET User Identity.
In Internet there are a lot of information teaching how to enable external login providers, but none teaches how to actually authenticate the user in the system when login returns to the MVC site. All information I have found assumes developer is using the
default ASP.NET identity user store, so it tells nothing about what to do next.
For example, in Google, when user selects the Google account, the call returns to the site and run the method FindAsync
of the custom user store, but, after that, how can I actually log the user in?
This is one my attempts to retrieve the user e-mail (in the custom user store class):
public Task<T> FindAsync(UserLoginIn fo login)
{
var info = AuthenticationManager.GetExternalLoginInfoAsync().Result;
var emailClaim = externalIdentity.Result.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Email);
}
But GetExternalLoginInfoAsync
does not belong to AuthenticationManager
object.
I have read that Microsoft.AspNet.Identity.Owin
should be included, but in my case, that NuGet package is already included, and of course, the corresponding using
statement
is present in the code.
I have seen that the callback function in AccountController does contain the user e-mail and username coming from the external provider but it calls the Find method of SigningManager only with part of the information containing a provider key and provider
name. That causes the Find method of custom user store to have a parameter I showed in the question . I can solve it by replacing the SigningManager method, but I think that is not the correct way to manage it.
Any help, please?