Handle failing refresh tokens
Catch the HTTPError caused by the server returning a 401 status code when an expired refresh code is used to refresh the token.
@@ -87,6 +87,12 @@ class Api(object):
})
IdentityManager.save(data, lock=False)
LOG.debug('Saved credentials')
+ except HTTPError as e:
+ if e.response.status_code == 401:
+ LOG.error('Could not refresh token, invalid refresh code.')
+ else:
+ raise
+
finally:
identity_lock.release()
else: # Someone is updating the identity wait for release
