Reputation: 81
I am using Google Sheets for my website to store certain order information. The problem I'm dealing with is that the access_token
expires within about an hour and the refresh_token
lasts me a couple of days at most before it expires.
Once my refresh_token
expires I have to:
The above process is manual, tedious and unbearable after a month.
Is there a better way?
Upvotes: 3
Views: 5025
Reputation: 116878
The problem I'm dealing with is that the access_token expires within about an hour and the refresh_token lasts me a couple of days at most before it expires.
Refresh tokens only last seven days if your application is still in testing. Go to Google cloud console and set it to production. Your refresh token will then stop expiring.
I am using Google Sheets for my website to store certain order information.
If you are only using a sheet that you the developer control. This meaning that you are not accessing sheets owned by your users on their own google drive accounts. Then you should consider using a Service account. Should you be using a Google service account
Upvotes: 3
Reputation: 201348
Unfortunately, I cannot understand your actual situation and your script, how about the following pattens?
In this pattern, the service account is used. When the service account is used, the access token can be retrieved without authorizing the scopes using the browser. You can use Sheets API using the access token.
In this pattern, Web Apps created by Google Apps Script is used. When Web Apps created by Google Apps Script is used, the Web Apps is used without the authorization process because when Web Apps is deployed, the authorization process is done. And, in this case, the Spreadsheet service can be used. So it is not required to use Sheets API. And, I think that Web Apps can be used as the wrapper API for Sheets API you are using. When you use this pattern, you can use Web Apps by an HTTP request.
Upvotes: 0