Issue
I created a datasource through a REST API connected to the Google Calendar API on Appsmith. The datasource keeps asking me to re-authorize every hour. I run API requests on the app and get an authentication error, then have to go back to the datasource, re-authorize and select my account again. It's becoming quite frustrating.
Resolution
The issue was that the user did not use the Authenticated REST API Datasource type. The user was requesting the access token with a regular REST API, then using that token in other API requests.
However, with OAuth2 datasources, the Authenticated REST API Datasource type should be used. This stores the credentials securely on the Appsmith server (instead of in the app definition), and also handles the access and refresh token requests.
Also see example OAuth2 connection configurations for Google Docs, Dropbox, Zoho and Harvest.