Getting invalid_grant and the token isn't refreshing. Below is how the authurl is being built and what is in the access token. I tried manually refreshing as well and it didn't work (again code below).
Relevant links:
https://github.com/google/google-api-nodejs-client
https://github.com/google/google-auth-library-nodejs
var authUrl = oauth2Client.generateAuthUrl({
access_type: 'offline',
scope: SCOPES
});
{"access_token":"XX","refresh_token":"XX","token_type":"Bearer","expiry_date":1}
oauth2Client.refreshAccessToken(function(err, tokens) {
oauth2Client.credentials = tokens;
storeToken(tokens);
pullSheetsData(oauth2Client);
});
Some more details: It works for ~8 hours then begins giving me invalid_grant. It doesn't matter if I am making any API calls or not, it always times out after that amount of time and I have to generate a new client secret if I want to continue. For example, I can generate a new client secret, run the quickstart, make 1 test call, turn off the app, and then try again in 8 hours and it will give me invalid_grant. When I first got my client secret, it worked for almost 1 1/2 months without any problems. Once it begin giving the error, it is always about the same amount of time.
I have looked at a variety of different proposed solutions, but none seem to work or fix my case. Most notably, this link proposed a long list of solutions but none seems to work.
Lastly, this is a server side node.js slack bot that is pulling data from a google sheet. I use the quickstart provided on google's developer page to generate the credentials. After that, the code above/in the application should be able to handle anything with the credentials. While testing, I never had this problem, but after moving it to docker, it began happening. It is now happening on or off docker, so I don't think that is relevant, but figured I should mention it.
Please forgive me if there is a really obvious mistake. This is my first app using Oauth2 and my first development side project at work. Any help or ideas would be great. Thanks.