我尝试使用 javacript SDK 获取访问令牌,然后将该访问令牌延长 60 天。我从响应中得到这样的响应错误:Object { message="Invalid OAuth access token.", type="OAuthException", code=190}
我的期望:
- 获取 60 天到期的新访问令牌
- 控制台到屏幕。
我的代码:
window.onload = function() {
var isLogin = true;
FB.init({appId:422642254433770, cookie:true, status:true, xfbml:true });
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// the user is logged in and connected to your
// app, and response.authResponse supplies
// the user’s ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
var accessTokenOld = response.authResponse.accessToken;
//Extend access token
var OauthParams = {};
OauthParams['client_id'] = '//REMOVED APP ID';
OauthParams['client_secret'] = '//REMOVED APP SECRET';
OauthParams['grant_type'] = 'fb_exchange_token';
OauthParams['fb_exchange_token'] = 'accessToken';
OauthParams['response_type'] = 'token';
console.log("Old accessToken => " + accessToken);
FB.api('/oauth/access_token', 'post', OauthParams, function(response) {
console.log(response);
if (!response || response.error) {
console.log(response.accesstoken);
} else {
console.log("Lay new access token bi loi " + response.error.message);
}
});
}
});
};
我尝试在没有任何线索的情况下在任何地方搜索这个问题 3 天。我有没有人有经验?请帮忙。
非常感谢