I\'ve successfully built an application that fetches an access and refresh token.
In my script I check if the access token is valid and if not I then use the refresh
In the OAuth2 spec, "invalid_grant" is sort of a catch-all for all errors related to invalid/expired/revoked tokens (auth grant or refresh token).
There's a lot potential causes for the problems, here's a checklist:
I've written a short article summarizing each item with some debugging guidance to help find the culprit. We spent days hunting this down, hope it may help others turn those days into hours.