From dd08e5754175ed187ffaac9cae674e6c4dedb373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Moyroud?= Date: Mon, 5 Mar 2018 17:59:47 -0800 Subject: [PATCH] Add support for Amazon's "Verification Needed" page at login In this case a page with a button to send a confirmation e-mail with a code pops up. We instruct the user to go to the Amazon webpage and perform the verification step. --- lib/kindle_highlights/client.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/kindle_highlights/client.rb b/lib/kindle_highlights/client.rb index 0d6c729..30a8310 100644 --- a/lib/kindle_highlights/client.rb +++ b/lib/kindle_highlights/client.rb @@ -2,6 +2,7 @@ module KindleHighlights class Client class CaptchaError < StandardError; end class AuthenticationError < StandardError; end + class ConfirmationError < StandardError; end class AsinNotFoundError < StandardError; end SIGNIN_FORM_IDENTIFIER = "signIn" @@ -72,6 +73,9 @@ def conditionally_sign_in_to_amazon elsif post_signin_page.search("#message_error > p").any? amazon_error = post_signin_page.search("#message_error > p").children.first.to_s.strip raise AuthenticationError, "Unable to sign in, received error: '#{amazon_error}'" + elsif post_signin_page.title == "Please confirm your identity" + confirmation_url = post_signin_page.uri.to_s + raise ConfirmationError, "Received a confirmation request while attempting to sign in to your Amazon account. You will need to resolve this manually at #{confirmation_url}" else @kindle_logged_in_page = post_signin_page end