I have social log in set up with federated authentication on a Sitecore 9 instance.
I am able to login with facebook from my front end site:
Where can a capture this 'hVEQItzjCrLQI1Fuc0v3pQ' on login? I looked up this blog post: http://blog.nikkipunjabi.com/2018/03/sitecore-federated-authentication-part-2-google-and-facebook-app-and-the-custom-processor.html
And the ProcessCore method does provide me with OnAuthenticated handler, but I dont see this sitecore generated user id in any object. I only see the claims data returned from facebook - I also checked in the handler for OnReturnEndpoint - and dont see it there too.
I am pretty much using the same code as in the example. Just added some code to show the login buttons on the front end site.
public class FacebookAuthentication : IdentityProvidersProcessor
{
public FacebookAuthentication(FederatedAuthenticationConfiguration federatedAuthenticationConfiguration) : base(federatedAuthenticationConfiguration)
{
}
protected override string IdentityProviderName => "Facebook";
protected override void ProcessCore(IdentityProvidersArgs args)
{
Assert.ArgumentNotNull(args, "args");
IdentityProvider identityProvider = GetIdentityProvider();
GetAuthenticationType();
FacebookAuthenticationProvider facebookProvider = new FacebookAuthenticationProvider
{
OnAuthenticated = context =>
{
// transform all claims
ClaimsIdentity identity = context.Identity;
foreach (Transformation current in identityProvider.Transformations)
{
current.Transform(identity, new TransformationContext(FederatedAuthenticationConfiguration, identityProvider));
}
return System.Threading.Tasks.Task.FromResult(0);
},
OnReturnEndpoint = (context) =>
{
if (context.Request.Query["state"] != null)
{
var state = HttpUtility.ParseQueryString(context.Request.Query["state"]);
//Tring stuff here, trying to resolve the sitecore user name hash from facebook info??
IOwinContext context1 = HttpContext.Current.GetOwinContext();
UserManager<ApplicationUser> userManager = context1.GetUserManager();
}
return System.Threading.Tasks.Task.FromResult(0);
}
};
IdentifyProviderCredentials credentials = IdentityProviderConfiguration.Current.GetCredentials(GetType().Name);
FacebookAuthenticationOptions options = new FacebookAuthenticationOptions
{
AppId = credentials.AppId,
AppSecret = credentials.AppSecret,
Provider = facebookProvider
};
options.Fields.Add("name");
options.Fields.Add("email");
options.Scope.Add("email");
args.App.UseFacebookAuthentication(options);
}
}
Any ideas?