Commit db305d71 authored by thibault douge's avatar thibault douge Committed by Vincent A

[amazon] management of the validation case by email

parent b50f9c69
Pipeline #3333 passed with stages
in 12 minutes and 58 seconds
......@@ -18,12 +18,15 @@
# along with this weboob module. If not, see <>.
from __future__ import unicode_literals
import time
from datetime import date
from weboob.browser import LoginBrowser, URL, need_login, StatesMixin
from weboob.exceptions import (
BrowserIncorrectPassword, BrowserUnavailable, ImageCaptchaQuestion, BrowserQuestion,
WrongCaptchaResponse, AuthMethodNotImplemented, NeedInteractiveFor2FA, BrowserPasswordExpired,
WrongCaptchaResponse, AuthMethodNotImplemented, NeedInteractiveFor2FA,
BrowserPasswordExpired, AppValidation, AppValidationExpired,
from import Value
from weboob.browser.browsers import ClientError
......@@ -107,6 +110,10 @@ class AmazonBrowser(LoginBrowser, StatesMixin):
# many captcha, reset value
self.config['captcha_response'] = Value(value=None)
msg_validation =
if 'approve the notification' in msg_validation:
raise AppValidation(msg_validation)
otp_type =
if otp_type == '/ap/signin':
# this otp will be always present until user deactivate it
......@@ -138,6 +145,19 @@ class AmazonBrowser(LoginBrowser, StatesMixin):
image =[0]).content
raise ImageCaptchaQuestion(image)
def check_app_validation(self):
# client has 60 seconds to unlock this page
timeout = time.time() + 60.00
while time.time() < timeout:
link =
raise AppValidationExpired()
def do_login(self):
if self.config['pin_code'].get():
# Resolve pin_code
......@@ -189,6 +209,9 @@ class AmazonBrowser(LoginBrowser, StatesMixin):, self.password)
if self.config['resume'].get():
if self.password_expired.is_here():
raise BrowserPasswordExpired(
......@@ -24,7 +24,7 @@ from weboob.capabilities.bill import DocumentTypes, CapDocument, Subscription, D
from weboob.capabilities.base import find_object, NotAvailable
from import Module, BackendConfig
from import urljoin
from import ValueBackendPassword, Value
from import ValueBackendPassword, Value, ValueTransient
from import html_to_pdf
from .browser import AmazonBrowser
......@@ -64,6 +64,7 @@ class AmazonModule(Module, CapDocument):
Value('captcha_response', label='Captcha Response', required=False, default=''),
Value('pin_code', label='OTP response', required=False, default=''),
Value('request_information', label='request_information', default=None, required=False, noprompt=True),
accepted_document_types = (DocumentTypes.BILL,)
......@@ -58,6 +58,14 @@ class SecurityPage(HTMLPage):
assert url in ('verify', '/ap/signin'), url
return url
def get_msg_app_validation(self):
msg = CleanText('//span[contains(@class, "transaction-approval-word-break")]')(self.doc)
if "To complete the sign-in, approve the notification sent to" in msg:
return msg
def get_link_app_validation(self):
return Link('//a[contains(text(), "Click here to refresh the page")]')(self.doc)
def get_otp_message(self):
return CleanText('//div[@class="a-box-inner"]/p')(self.doc)
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