peburrows / goth

Elixir package for Oauth authentication via Google Cloud APIs
http://hexdocs.pm/goth
MIT License
289 stars 111 forks source link

Treat expired tokens as missing #3

Closed amuino closed 8 years ago

amuino commented 8 years ago

Sometimes (at least happens on dev machines which go to sleep), the tokens are not being automatically refreshed (probably because the erlang time lags behind the os time, and also because :timer.apply_after only guarantees "not sooner than", but can be much later), which causes authentication issues.

This commit checks the expires value against the OS time and, if the token (although present on the TokenStore) has expired, it is removed and an :error is returned (same as if it were missing). This will cause a new token to be requested.

peburrows commented 8 years ago

Good idea!

I'll get this merged and roll a new release later this evening.