Ich versuche, Facebook-Login auf meiner Website (MVC 5) einzurichten, aber ich habe ein Problem, das ich schon seit ein paar Tagen nicht überwinden kann.MVC 5 Facebook Login Zugriff verweigert
Alles funktioniert perfekt auf localhost, aber bei der Bereitstellung in Testumgebung oder Produktion funktioniert es nicht. Ich bekomme immer "http://stage.automasy.com/Account/ExternalLoginCallback?error=access_denied#=" und ich verstehe nicht warum.
Ich habe alles in Facebook Entwickler-Konto konfiguriert, die App zeigt grün.
Dies ist Teil meines Code:
In Startup.Auth:
var options = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationOptions
{
AppId = "xxx",
AppSecret = "xxx",
CallbackPath = new PathString("/signin-facebook"),
BackchannelHttpHandler = new Services.FacebookBackChannelHandler(),
UserInformationEndpoint = "https://graph.facebook.com/v2.8/me?fields=id,name,email,first_name,last_name"
};
options.Provider = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationProvider()
{
OnAuthenticated = (context) =>
{
context.Identity.AddClaim(new System.Security.Claims.Claim("FacebookAccessToken", context.AccessToken));
foreach (var claim in context.User)
{
var claimType = string.Format("urn:facebook:{0}", claim.Key);
string claimValue = claim.Value.ToString();
if (!context.Identity.HasClaim(claimType, claimValue))
context.Identity.AddClaim(new System.Security.Claims.Claim(claimType, claimValue, "XmlSchemaString", "Facebook"));
}
return System.Threading.Tasks.Task.FromResult(0);
}
};
options.SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie;
options.Scope.Add("email");
options.Scope.Add("public_profile");
app.UseFacebookAuthentication(options);
und in Account:
public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null)
{
return RedirectToAction("Login");
}
ich aus Ideen bin ... also wenn jemand kann mir helfen, ich würde es begrüßen.
Danke!
Ich habe ein ähnliches Problem. Sobald ich den Provider, CallbackPath, BackchannelHttpHandler und UserInformationEndpoint nicht eingestellt habe, funktioniert es. Aber ich habe immer noch keinen Zugang zu den Claims ... – Ewert