Reputation: 387
I'm getting invalid_grant
error when creating a draft.
Scopes I requested:
https://www.googleapis.com/auth/gmail.modify
https://www.googleapis.com/auth/userinfo.profile
https://www.googleapis.com/auth/contacts.readonly
https://www.google.com/m8/feeds/
https://mail.google.com/
https://www.googleapis.com/auth/gmail.settings.basic
https://www.googleapis.com/auth/calendar
I use python library to interact with Gmail API ( The main problem is that this sometimes works as expected, sometimes it doesn't work and I don't know why. My code look like the one from example here: https://developers.google.com/gmail/api/v1/reference/users/drafts/create
Upvotes: 0
Views: 170
Reputation: 13494
Based from this thread, the possible problems that cause invalid_grant errors are if your server's clock is out of sync with NTP and/or you've exceeded the refresh token limit. This page also suggested to make sure that you specify access_type=offline
in your request.
Here's a related SO post for a checklist of potential causes for the problems:
- Server clock/time is out of sync
- Not authorized for offline access
- Throttled by Google
- Using expired refresh tokens
- User has been inactive for 6 months
- Use service worker email instead of client ID
- Too many access tokens in short time
- Client SDK might be outdated
- Incorrect/incomplete refresh token
- User has actively revoked access to our app
- User has reset/recovered their Google password
Hope this helps!
Upvotes: 2