Commit 2c9afc52 authored by Célande Adrien's avatar Célande Adrien Committed by Romain Bignon

[n26] wrongpass because of bad exception

A lot of wrongpass appeared on n26 connector.
It is because when tying to login, after a number of failures, you cannot log in right away.
You need to wait 30 minutes, that is what is said by a message.

Now the message is retrieved in a BrowserUnavailble exception.
The BrowserIncorectPassword also has an error message.

Closes: 6279@zendesk
Closes: 6520@zendesk
parent ae266b89
......@@ -25,7 +25,7 @@ from weboob.browser.browsers import DomainBrowser
from weboob.capabilities.base import find_object, NotAvailable
from weboob.capabilities.bank import Account, Transaction, AccountNotFound
from weboob.browser.filters.standard import CleanText
from weboob.exceptions import BrowserIncorrectPassword
from weboob.exceptions import BrowserIncorrectPassword, BrowserUnavailable
from weboob.browser.exceptions import ClientError
# Do not use an APIBrowser since APIBrowser sends all its requests bodies as
......@@ -74,8 +74,16 @@ class Number26Browser(DomainBrowser):
try:
result = self.request('/oauth/token', data=data, method="POST")
except ClientError:
raise BrowserIncorrectPassword()
except ClientError as ex:
response = ex.response.json()
if response.get('error') == 'invalid_grant':
raise BrowserIncorrectPassword(response['error_description'])
if response.get('title') == 'Error':
raise BrowserUnavailable(response['message'])
raise
self.auth_method = 'bearer'
self.bearer = result['access_token']
......
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