janvda / node-red-contrib-google-photos

Node-RED node for Google APIs using OAuth2.
MIT License
0 stars 0 forks source link

No automatic refresh of authentication token #7

Open janvda opened 5 years ago

janvda commented 5 years ago

If the application is running more than 1 hour then the authentication expires and the application is not automatically refreshing it.

The following message is seen:

msg : error
"StatusCodeError: 401 - {"error":{"code":401,"message":"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status":"UNAUTHENTICATED"}}"
janvda commented 5 years ago

As workaround you can restart the node-red application as during startup the token becomes refreshed.

janvda commented 4 years ago

see https://github.com/roopakv/google-photos/issues/19

janvda commented 4 years ago

Design proposal:

  1. Access and refresh token are stored in a file + expiry time of access token.
  2. Every 45 minutes tokens are refreshed using the refresh token. The refreshed tokens and new expiry time are stored to file (see point 1). If access token is updated then updated access token is stored. node.photos is deleted and reinitialized using new access token