我有以下代码,其中抓取了First / Last名称。我意识到电子邮件是一个扩展权限,但我需要修改什么才能请求扩展权限?
如何通过DotNetOpenAuth
fbClient = new FacebookClient
{
ClientIdentifier = ConfigurationManager.AppSettings["facebookAppID"],
ClientSecret = ConfigurationManager.AppSettings["facebookAppSecret"],
};
IAuthorizationState authorization = fbClient.ProcessUserAuthorization();
if (authorization == null)
{
// Kick off authorization request
fbClient.RequestUserAuthorization();
}
else
{
var request = WebRequest.Create("https://graph.facebook.com/me?access_token=" + Uri.EscapeDataString(authorization.AccessToken));
using (var response = request.GetResponse())
{
using (var responseStream = response.GetResponseStream())
{
var graph = FacebookGraph.Deserialize(responseStream);
// unique id for facebook based on their ID
FormsAuthentication.SetAuthCookie("fb-" + graph.Id, true);
return RedirectToAction("Index", "Admin");
}
}
}
return View("LogOn");
答案 0 :(得分:11)
添加以下位:
var scope = new List<string>();
scope.Add("email");
fbClient.RequestUserAuthorization(scope);
答案 1 :(得分:1)
如果您使用内置oauth提供程序的VS2012,则只需更新oauth包。请参阅以下链接上的最后一篇文章:http://forums.asp.net/t/1847724.aspx/1。我无法检索的唯一电子邮件是MS Live。目前我使用facebook,google和yahoo。