Javascript 使用c中的身份验证令牌获取用户详细信息#
我使用的是servicestack,在客户端,我使用的是facebook身份验证,它将提供一个accesstoken post登录Javascript 使用c中的身份验证令牌获取用户详细信息#,javascript,c#,facebook,authentication,servicestack,Javascript,C#,Facebook,Authentication,servicestack,我使用的是servicestack,在客户端,我使用的是facebook身份验证,它将提供一个accesstoken post登录 function testAPI() { console.log('Welcome! Fetching your information.... '); FB.api('/me', function(response) { console.log('Successful login for: ' + response.name);
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Successful login for: ' + response.name);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + '!';
});
}
身份验证完成后,将设置一个cookie值fbsr\u Appid
,该值将包含身份验证令牌
当用户向servicestack发出请求时,我将能够从上下文中的cookie值中获取此身份验证令牌那么现在,我如何使用此令牌获取用户的用户ID/电子邮件ID?
目前,我可以使用下面的url获取访问令牌的到期时间
https://graph.facebook.com/oauth/access_token_info?client_id=APPID&access_token=xxxxxxxxx
以下面的格式返回响应
{
access_token: "xxxxxxxx",
token_type: "bearer",
expires_in: 5560
}
最后我想出了一个办法
var details = string.Format("https://graph.facebook.com/me?access_token={0}", token);
这是以下面的格式给出的响应
{
id: "344657773358323",
email: "zz@gmail.com",
first_name: "xxxxxx",
gender: "male",
last_name: "xxxxxx",
link: "https://www.facebook.com/app_scoped_user_id/xxxxx/",
locale: "en_US",
name: "xxxx xxxx",
timezone: 5.5,
updated_time: "xx-xx-xx:07:xx+0000",
verified: true
}