0
我想扩展我的Facebook访问令牌,以下是我所做的。但是,我无法获得令牌扩展,并且当我检查facebook accesstoken调试器时,它仍然显示该令牌将在一小时内过期。无法扩展Facebook访问令牌
有什么想法?
private string appId = "my app id";
private string appSecret = "my app secret";
private string returnUrl = "http://localhost:1868/callback";
private string _scope = "user_about_me,publish_stream,user_videos,user_photos";
[Test]
public void GetFacebookLoginUrl()
{
var fb = new FacebookClient();
dynamic result = fb.GetLoginUrl(
new
{
client_id = appId,
client_secret = appSecret,
redirect_uri = returnUrl,
response_type = "code",
scope = _scope
}
);
}
[Test]
public void exchangeCodeForAccessToken()
{
var fb = new FacebookClient();
dynamic result = fb.Get("oauth/access_token", new
{
client_id = appId,
client_secret = appSecret,
redirect_uri = returnUrl,
code = "got the code after user accepts the request"
});
}
[Test]
public void ExtendExpiryTimeOfAccessToken()
{
var fb = new FacebookClient();
dynamic result = fb.Get("oauth/access_token", new
{
client_id = appId,
client_secret = appSecret,
grant_type = "fb_exchange_token",
fb_exchange_token = "token from preview method"
});
}
解决方案
后去检查从用户的帐户的一切相关应用决策意识。 有一点需要注意, 上面的代码实际上获得了一个“长期存取”的访问令牌,它有效期为60天,并且它不能被扩展。
如果使用Facebook client-side authentication,那么可以使用“ExtendExpiryTimeOfAccessToken”示例对其进行扩展。
是的,我认为这是原因,我必须取消授权,然后一切都开始有意义。 – Eatdoku
希望Facebook能够尽快解决这个问题,但是考虑到目前为止我已经采取了多长时间了,我并没有屏住呼吸 – ArthurGuy
@ArthurGuy你的意思是每个用户都必须取消授权/删除应用程序并重新添加它? – jrummell