Closed lsorber closed 3 years ago
Thanks for the report, @lsorber! It makes sense, I will have a look.
Quick fix is in master. As a compromise, I set the max lifetime of a token to 6 hours. Would you agree, @lsorber ? If there're no questions I'd push the new version to pypi on Friday.
Initially I thought of automatically renewing token if "Token has expired" message is received. But on the other hand, if this happens then something is wrong on the server side or the logic of token validation has changed. So I think, it is better to explicitly address this issue rather than swallow it.
LGTM, thank you!
PyDatastream 0.6.4 with the fix is in the pypi
We're observing occurences of
InvalidToken
exceptions when calling therequest_many
function (see screenshot below).There are two underlying issues that need to be addressed in
_token_is_expired
property:TokenExpiry
is a UTC datetime, but is compared with the local datetimepd.Timestamp('now')
. Suggestion for line 195:if self._token['TokenExpiry'] < pd.Timestamp.utcnow() - pd.Timedelta(minutes=15):
.Screenshot: