【发布时间】:2017-09-24 11:39:18
【问题描述】:
我正在尝试使用 OAuth2 API 使用 Google API Node.js 客户端检索登录用户的名称。
按照使用示例,我设法进行了登录,但我找不到获取个人资料信息的方法。
我没有使用 People API 或 Plus API,因为据我所知,OAuth2 包括 https://www.googleapis.com/auth/userinfo.profile,这应该足以完成任务。
我看到了一些类似的问题并尝试了这个的解决方案,但它没有奏效,也许它太旧了(?)
With the npm package googleapis how do I get the user's email address after authenticating them?
查看其他 API,例如 Google Sheets,可以像这样调用它们的函数:
var google = require('googleapis');
var sheets = google.sheets('v4');
...
sheets.spreadsheets.values.get({
auth: auth,
spreadsheetId: file_id,
range: my_ranges,
}, function(err, response){
...
}
);
但似乎 OAuth2 不能那样工作......
【问题讨论】:
标签: node.js google-api oauth-2.0