ASP.NET MVC 5.1 C#实OWIN认证或登录索要的生日,喜欢的公众形象,电话号码 [英] ASP.NET MVC 5.1 C# OWIN facebook authentication or login ask for birthday, likes, public profile, phone number
问题描述
我已经看到了Facebook验证的许多职位,无论是那些旧的或无法正常工作,因为它应该的。
I have seen many posts for facebook authentication , either those are old or not working correctly as it should be.
不过最后我做了我的项目工作,但没有完全的东西。这里是code,我问
However finally I have made something in my project that works but not fully. Here is code where I ask for
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);
任何人都可以请帮我,为什么我没有得到friends_like,生日,user_likes等。
Can anyone please help me why I am not getting friends_like,birthday, user_likes and so on.
另外,如何让这些字符串值(即user_birthday,FIRST_NAME)进行信息检索,就像我怎么会知道user_birthday返回生日(我是从搜索得到的话)的日期,是否有其中有这样的字符串名称的列表(即user_birthday,FIRST_NAME)?
In addition, how to get those string values(ie. "user_birthday","first_name") for information retrieval, like how would I know that "user_birthday" returns date of birthday(I got it from searching) , is there any list which have this string names(ie. "user_birthday","first_name") ?
如果我使用谷歌认证是有可能得到的电话号码或名字,姓氏?
If I use google authentication is it possible to get phone number or first name,last name?
推荐答案
解决它,
参考文献有:<一href=\"https://developers.facebook.com/docs/facebook-login/permissions/v2.1#reference\">https://developers.facebook.com/docs/facebook-login/permissions/v2.1#reference
var facebookAuthenticationOptions = new FacebookAuthenticationOptions() {
AppId = ".....",
AppSecret = ".....",
AuthenticationType = "Facebook",
SignInAsAuthenticationType = "ExternalCookie",
Provider = new FacebookAuthenticationProvider {
OnAuthenticated = async ctx => {
ctx.Identity.AddClaim(new Claim(ClaimTypes.DateOfBirth, ctx.User["birthday"].ToString()));
ctx.Identity.AddClaim(new Claim(ClaimTypes.Country, ctx.User["birthday"].ToString()));
ctx.Identity.AddClaim(new Claim(ClaimTypes.Gender, ctx.User["birthday"].ToString()));
ctx.Identity.AddClaim(new Claim(ClaimTypes.MobilePhone, ctx.User["birthday"].ToString()));
ctx.Identity.AddClaim(new Claim(ClaimTypes.OtherPhone, ctx.User["birthday"].ToString()));
ctx.Identity.AddClaim(new Claim(ClaimTypes.HomePhone, ctx.User["birthday"].ToString()));
ctx.Identity.AddClaim(new Claim(ClaimTypes.StateOrProvince, ctx.User["birthday"].ToString()));
ctx.Identity.AddClaim(new Claim(ClaimTypes.Email, ctx.User["birthday"].ToString()));
ctx.Identity.AddClaim(new Claim(ClaimTypes.Country, ctx.User["birthday"].ToString()));
ctx.Identity.AddClaim(new Claim(ClaimTypes.Actor, ctx.User["birthday"].ToString()));
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");
facebookAuthenticationOptions.Scope.Add("publish_stream");
facebookAuthenticationOptions.Scope.Add("user_likes");
facebookAuthenticationOptions.Scope.Add("friends_likes");
facebookAuthenticationOptions.Scope.Add("user_about_me");
facebookAuthenticationOptions.Scope.Add("user_friends");
facebookAuthenticationOptions.Scope.Add("user_actions.news");
facebookAuthenticationOptions.Scope.Add("user_actions.video");
facebookAuthenticationOptions.Scope.Add("user_education_history");
facebookAuthenticationOptions.Scope.Add("manage_pages");
facebookAuthenticationOptions.Scope.Add("user_interests");
facebookAuthenticationOptions.Scope.Add("user_location");
facebookAuthenticationOptions.Scope.Add("user_photos");
facebookAuthenticationOptions.Scope.Add("user_relationships");
facebookAuthenticationOptions.Scope.Add("user_relationship_details");
facebookAuthenticationOptions.Scope.Add("user_status");
facebookAuthenticationOptions.Scope.Add("user_tagged_places");
facebookAuthenticationOptions.Scope.Add("user_videos");
facebookAuthenticationOptions.Scope.Add("user_website");
facebookAuthenticationOptions.Scope.Add("read_friendlists");
facebookAuthenticationOptions.Scope.Add("read_stream");
facebookAuthenticationOptions.Scope.Add("email");
app.UseFacebookAuthentication(facebookAuthenticationOptions);
CTX得到了所有的信息..只是要经过它。
还没有关于如何获取谷歌第一,姓氏和电话号码+出生日期信息。
或如何从Gmail帐户访问用户联系人。的
Still don't have information on how to get google first,last name and phone number + date of birth. Or how to access user contacts from gmail account.
这篇关于ASP.NET MVC 5.1 C#实OWIN认证或登录索要的生日,喜欢的公众形象,电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!