Gmail API throwing 401 Unauthorized

419 views Asked by At

I'm trying to integrate Gmail API in my app in order to send emails to users. i've created a project on Google Developers Console, enabled Gamil API in it, downloaded the credentials as JSON and followed the instruction provided at https://developers.google.com/gmail/api/quickstart/nodejs

I've also added https://developers.google.com/oauthplayground as a redirect URI for the project. When I run the code, I get redirected to a consent screen. I choose the account which has the project, then get redirected to "oauthplayground"

However, when I try to exchange authorization code for tokens, I receive 401 unauthorized

the full response is:

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"
}

Any help is appreciated Thanks

0

There are 0 answers