从今天开始,我无法通过向该网址发出 GET 请求来检索我的 Google+ 活动:
https://www.googleapis.com/plus/v1/people/me/activities/public?key={API_KEY}
我收到 401 错误。所以我尝试使用 node.js oauth2 库对请求进行签名,包括预先生成的用户令牌,但我得到了同样的错误。我的测试脚本的js代码是:
var OAuth2 = require('oauth').OAuth2,
GOOGLEPLUS_APP_ID = {APP_ID},
GOOGLEPLUS_APP_SECRET = {APP_SECRET},
accessToken = {USER_TOKEN};
var _oauth2 = new OAuth2(GOOGLEPLUS_APP_ID, GOOGLEPLUS_APP_SECRET, '',
'https://accounts.google.com/o/oauth2/auth',
'https://accounts.google.com/o/oauth2/token');
_oauth2.get('https://www.googleapis.com/plus/v1/people/me/activities/public?key={API_KEY}',
accessToken, function (err, body, res) {
if (err) {
console.log('error:');
console.log(err);
}
else console.log(body);
});
我提出了相同的请求以获取基本用户信息(网址:https ://www.googleapis.com/oauth2/v1/userinfo )并且工作正常。
你能帮我解决这个问题吗?
谢谢你。