Commit 7d42703d authored by Augustin Bouverot's avatar Augustin Bouverot Committed by Vincent Ardisson

[n26] Handle 405 errors

We can randomly get a 405 error back from our first request in the
do_login(), causing a crash while trying to parse the empty response body
as json.
parent ef3bd4f0
......@@ -140,6 +140,9 @@ class Number26Browser(DomainBrowser, StatesMixin):
try:
result = self.request('/oauth2/token', data=data)
except ClientError as ex:
# sometime we get a random 405 back from our first request, there is no response body.
if ex.response.status_code == 405:
raise BrowserUnavailable()
json_response = ex.response.json()
if json_response.get('title') == 'A second authentication factor is required.':
self.mfaToken = json_response.get('mfaToken')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment