从客户端登录并在服务器端接收访问令牌后,我想调用Google API获取信息。我可以在服务器端调用google API,没有插入API密钥和其他凭据,但只能使用访问令牌吗?
类似的东西:
plus.people.get({
resourceName: 'people/me',
personFields: 'emailAddresses,names',
auth: accessToken}, (err, response) => {
console.log(response);
});
我实际上正在使用node.js
答案 0 :(得分:1)
我知道你想使用access.get使用访问令牌。如果我的理解是正确的,那么这个示例脚本怎么样?
var google = require('googleapis');
var plus = google.people('v1');
var OAuth2 = google.auth.OAuth2;
var oauth2Client = new OAuth2();
oauth2Client.setCredentials({access_token: accessToken});
plus.people.get({
resourceName: 'people/me',
personFields: 'emailAddresses,names',
auth: oauth2Client}, (err, response) => {
console.log(response);
});
如果我误解了你的问题,我很抱歉。