Have invalid grant error
See original GitHub issueError: invalid_grant
at createError (/user_code/node_modules/googleapis/node_modules/axios/lib/core/createError.js:16:15)
at settle (/user_code/node_modules/googleapis/node_modules/axios/lib/core/settle.js:18:12)
at IncomingMessage.handleStreamEnd (/user_code/node_modules/googleapis/node_modules/axios/lib/adapters/http.js:201:11)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
I first get the authenticationCode in front end using
gapi.auth2.getAuthInstance().grantOfflineAccess()
and send the code to server side (server side is firebase cloud functions)
and in server side, I tried like following.
const oauth2Client = new google.auth.OAuth2(
"XXX",
"XXX",
"XXX"
);
oauth2Client.getToken(authenticationCode) // authenticationCode is from front end
When I got the error. Any idea how to fix it?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:11 (5 by maintainers)
Top Results From Across the Web
How to interpret and resolve the "Invalid Grant" error for ...
This happens when the user that connected the Google Data Source in Databox has their permissions changed or revoked to the Google Account....
Read more >Google OAuth “invalid_grant” nightmare — and how to fix it
Google OAuth “invalid_grant” nightmare — and how to fix it · 1) Server clock/time is out of sync · 2) Not authorized for...
Read more >"invalid_grant" error when requesting an OAuth Token
Issue symptoms. When I attempt to obtain an access token, I receive the error below. {"error":"invalid_grant",
Read more >OAuth2 "Invalid Grant" response from server - Stack Overflow
I got annoyed by invalid_grant error instead of the fact that same code is getting me correct access token some times. Shaikh's answer...
Read more >InvalidGrantError — oauth2-server 4.0.0-dev.2 documentation
The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m having this same problem right now. My front-end is running with ReactJS to get code token (GAPI).
In my Express server I run the googleapis to get token, but not working.
Error data:
@reidark, maybe this will help: https://medium.com/@chaimmw86/thanks-for-the-article-really-helpful-36970b83e8a9. I also had this problem in the past, review my configuration following this: https://medium.com/@nickroach_50526/sending-emails-with-node-js-using-smtp-gmail-and-oauth2-316fe9c790a1 and then added the
tls: { rejectUnauthorized: false }
now is working, hope that help