【发布时间】:2020-10-16 03:12:46
【问题描述】:
我正在尝试使用 Gmail API。使用 POSTMAN 我创建了 oAuth 2.0 令牌并能够访问 URL https://www.googleapis.com/gmail/v1/users/xyz@gmail.com/profile。但是当我尝试与我的节点项目相同时,我使用以下方法调用相同的:
app.get('/getMail',getMail);在我的index.js里面getMail如下
exports.getMail = (req, res) => {
request({
url: "https://www.googleapis.com/gmail/v1/users/xyz@gmail.com/profile",
method: "GET",
headers: {
Authorization: 'Bearer token'
},
json: true
}, function(response) {
console.log(JSON.stringify(response, null, 4));
return res.json(response);
});
但我得到的响应为空。任何帮助将不胜感激。
【问题讨论】: