Fix #62 by making the login and logout systems more resilient to expired API keys.
A new USGSAuthExpiredError exception was added that is thrown when an "AUTH_EXPIRED" response is received. This occurs if a request is made with an expired API key.
api.logout now does nothing if api.TMPFILE does not exist. This prevents logout attempts with an empty API key that would otherwise fail.
api.logout now ignores USGSAuthExpiredError exceptions which would otherwise prevent it from deleting an expired API key. Other exceptions will still prevent key deletion, which ensures that a key is not accidentally deleted if it is not correctly logged out (i.e. if the request fails for a different reason).
api.login now uses api._check_for_usgs_error to validate responses like the rest of the api module. This ensures that USGSAuthExpiredError (and it's hint to log out first) will be thrown if a login is attempted with an expired API key.
Let me know what you think, @kapadia. I'm happy to make changes :)
Fix #62 by making the login and logout systems more resilient to expired API keys.
USGSAuthExpiredError
exception was added that is thrown when an "AUTH_EXPIRED" response is received. This occurs if a request is made with an expired API key.api.logout
now does nothing ifapi.TMPFILE
does not exist. This prevents logout attempts with an empty API key that would otherwise fail.api.logout
now ignoresUSGSAuthExpiredError
exceptions which would otherwise prevent it from deleting an expired API key. Other exceptions will still prevent key deletion, which ensures that a key is not accidentally deleted if it is not correctly logged out (i.e. if the request fails for a different reason).api.login
now usesapi._check_for_usgs_error
to validate responses like the rest of theapi
module. This ensures thatUSGSAuthExpiredError
(and it's hint to log out first) will be thrown if a login is attempted with an expired API key.Let me know what you think, @kapadia. I'm happy to make changes :)