Jude
Jude

Reputation: 11

How to get tokens valid for longer than 24h

I'm trying to get a token valid for a long time and I am not sure how to proceed. I'm sending data to a Google Sheet on a daily basis so a 24h token doesn't allow me to have this automated.

Thanks

Upvotes: 0

Views: 315

Answers (2)

Jude
Jude

Reputation: 11

I have since found a way to make my script work. In the script, do not include the access token, ONLY the refresh token.

By having both, it prevented the refresh token of getting a new token and was simply using the expired token.

Upvotes: 1

CMB
CMB

Reputation: 5163

The generic way of obtaining tokens expiring longer than 24 hours is to get a refresh token. You can start by reading the instructions here:

Using OAuth 2.0 to Access Google APIs

Get Refresh Tokens

Refreshing Access Tokens

Upvotes: 0

Related Questions