Gmail API抛出401未经授权

时间:2020-10-21 08:04:10

标签: node.js gmail-api oauth2-playground

我正在尝试将Gmail API集成到我的应用中,以便向用户发送电子邮件。 我已经在Google Developers Console上创建了一个项目,并在其中启用了Gamil API,并以JSON格式下载了凭据,并按照https://developers.google.com/gmail/api/quickstart/nodejs

中提供的说明进行操作

我还添加了https://developers.google.com/oauthplayground作为项目的重定向URI。 运行代码时,我将重定向到同意屏幕。我选择有项目的帐户,然后将其重定向到“ oauthplayground”

但是,当我尝试用令牌交换授权码时,会收到401条未经授权的

完整的答复是:

HTTP/1.1 401 Unauthorized
Content-length: 75
X-xss-protection: 0
X-content-type-options: nosniff
Transfer-encoding: chunked
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Vary: Origin, X-Origin, Referer
Server: scaffolding on HTTPServer2
-content-encoding: gzip
Pragma: no-cache
Cache-control: no-cache, no-store, max-age=0, must-revalidate
Date: Wed, 21 Oct 2020 07:53:18 GMT
X-frame-options: SAMEORIGIN
Alt-svc: h3-Q050=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Content-type: application/json; charset=utf-8
{
  "error_description": "Unauthorized", 
  "error": "unauthorized_client"
}

感谢您的帮助 谢谢

0 个答案:

没有答案