This is my custom provider class:
public class Facebook : IdentityProvidersProcessor
{
public Facebook(FederatedAuthenticationConfiguration federatedAuthenticationConfiguration,
ICookieManager cookieManager,
BaseSettings settings)
: base(federatedAuthenticationConfiguration, cookieManager, settings)
{
}
protected override string IdentityProviderName => "Facebook";
protected override void ProcessCore(IdentityProvidersArgs args)
{
Assert.ArgumentNotNull(args, nameof(args));
var identityProvider = this.GetIdentityProvider();
var authenticationType = this.GetAuthenticationType();
var options = new FacebookAuthenticationOptions
{
Caption = identityProvider.Caption,
AuthenticationType = authenticationType,
AuthenticationMode = AuthenticationMode.Passive,
AppId = Settings.GetSetting("Feature.Accounts.Facebook.AppId"),
AppSecret = Settings.GetSetting("Feature.Accounts.Facebook.AppSecret"),
Provider = new FacebookAuthenticationProvider
{
OnAuthenticated = context =>
{
context.Identity.ApplyClaimsTransformations(new TransformationContext(this.FederatedAuthenticationConfiguration, identityProvider));
AddClaim(context, "full_name", "name");
AddClaim(context, "email", "email");
return Task.CompletedTask;
}
},
Scope =
{
"public_profile",
"email"
},
Fields =
{
"name",
"email",
}
};
FacebookAuthenticationExtensions.UseFacebookAuthentication(args.App, options);
}
private void AddClaim(FacebookAuthenticatedContext context, string claimName, string propertyName)
{
var value = context.User[propertyName]?.ToString();
if (propertyName == "picture")
{
value = context.User["picture"]?["data"]?["url"]?.ToString();
if (value == null)
return;
context.Identity.AddClaim(new Claim("picture_url", value));
context.Identity.AddClaim(new Claim("picture_mime", "image/jpg"));
return;
}
if (value == null)
return;
context.Identity.AddClaim(new Claim(claimName, value));
}
}
So i am able to login by using facebook successfully but whenever i am changing the page the cache whatever i added at the time of facebook login getting removed.