我正在尝试将 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"
}
感谢任何帮助谢谢