Ich habe viele Beiträge für Facebook-Authentifizierung gesehen, entweder die sind alt oder nicht richtig funktioniert, wie es sein sollte.ASP.NET MVC 5.1 C# OWIN Facebook-Authentifizierung oder Login Fragen Sie nach Geburtstag, Likes, öffentliches Profil, Telefonnummer
Aber schließlich habe ich etwas in meinem Projekt gemacht, das funktioniert aber nicht vollständig. Hier ist der Code, wo ich fragen Sie nach
var facebookAuthenticationOptions = new FacebookAuthenticationOptions()
{
AppId = "...ID",
AppSecret = "...AppSecret",
AuthenticationType = "Facebook",
SignInAsAuthenticationType = "ExternalCookie",
//Provider = new FacebookAuthenticationProvider
//{
// OnAuthenticated = async ctx =>
// {
// if (ctx.User["birthday"] != null)
// {
// ctx.Identity.AddClaim(new Claim(ClaimTypes.DateOfBirth,ctx.User["birthday"].ToString()));
// }
// }
//}
};
facebookAuthenticationOptions.Scope.Add("user_birthday");
//facebookAuthenticationOptions.Scope.Add("first_name");
//facebookAuthenticationOptions.Scope.Add("last_name");
//page goes blank if ask for first_name,last_name , if comment out works
//but doesn give date of birth or likes or other things.
facebookAuthenticationOptions.Scope.Add("publish_stream");
facebookAuthenticationOptions.Scope.Add("user_likes");
facebookAuthenticationOptions.Scope.Add("friends_likes");
facebookAuthenticationOptions.Scope.Add("read_stream");
facebookAuthenticationOptions.Scope.Add("email");
app.UseFacebookAuthentication(facebookAuthenticationOptions);
Kann jemand bitte helfen Sie mir, warum ich nicht friends_like, Geburtstag bekommen, user_likes und so weiter.
Darüber hinaus, wie diese String-Werte (dh. "User_birthday", "first_name") für den Informationsabruf, wie würde ich wissen, dass "user_birthday" Datum der Geburtstags (ich habe es von der Suche) zurückgibt, ist Gibt es irgendeine Liste, die diese String-Namen haben (zB. "user_birthday", "first_name")?
Wenn ich Google Authentifizierung verwende, ist es möglich, Telefonnummer oder Vorname, Nachname zu bekommen?
Danke. Ich habe den ganzen Tag geschwitzt. – bowerm
Vielen Dank ~! Für mich geht das! Das einzige Problem ist, dass die erstellten Claim-Objekte nicht in meiner Datenbank gespeichert werden. Was soll ich noch tun, damit es funktioniert? – Franva
@Franva müssen Sie es von der Controller-Seite behandeln, müssen Sie auf diese Eigenschaften zugreifen und diese in db speichern. –