Kubessandra / react-google-calendar-api

An api to manage your google calendar
MIT License
215 stars 88 forks source link

Refresh or save Token to localStorage #101

Closed totoluto closed 1 year ago

totoluto commented 1 year ago

Is there a way to access the token or safe the token to the localStorage and retrieve it when accessing the website? And if yes is there a way to refresh the token when it has expired? I shouldn't be the first one to face that problem. How did you solve it? Are you always logging back in when accessing the website? Thanks for the greate package btw.

OchotaDariusz commented 1 year ago

@totoluto

By default, OAuth 2.0 access tokens are valid for a maximum of 1 hour (3,600 seconds).

https://developers.google.com/identity/protocols/oauth2#expiration

If you want to refresh the token, call again handleAuthClick i think

totoluto commented 1 year ago

@OchotaDariusz Thank you, and what about saving the token or session? Is there any use to it?

OchotaDariusz commented 1 year ago

I think there's possibility to do that but you'll have to modify code to add getter for tokenClient field. But how about refreshing token then you should read google docs about that. Good luck :)

totoluto commented 1 year ago

Thank you!