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.
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 theTokenStore
) 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.