gpt4 book ai didi

facebook - DotNetOpenAuth 获取 Facebook 电子邮件地址

转载 作者:行者123 更新时间:2023-11-30 05:17:50 25 4
gpt4 key购买 nike

我有以下代码,其中获取名字/姓氏。我知道电子邮件是一种扩展权限,但我需要修改什么才能请求扩展权限?

如何通过 DotNetOpenAuth 获取经过身份验证的 Facebook 用户的电子邮件?

        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");

最佳答案

添加以下位:

            var scope = new List<string>();
scope.Add("email");
fbClient.RequestUserAuthorization(scope);

关于facebook - DotNetOpenAuth 获取 Facebook 电子邮件地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5356409/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com