Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Captcha Login Fails 'KeyError' #73

Closed
CuriousEl3phant502 opened this issue Nov 29, 2021 · 17 comments · Fixed by #80
Closed

Captcha Login Fails 'KeyError' #73

CuriousEl3phant502 opened this issue Nov 29, 2021 · 17 comments · Fixed by #80

Comments

@CuriousEl3phant502
Copy link

CuriousEl3phant502 commented Nov 29, 2021

using:
audible 0.6.0
Python 3.10

When trying to login using captcha method, login fails due to an exception 'KeyError'.

I am using a captcha call back but the guess seems to be coming back correctly on ln 376.

In line 388 of login.py ( last line in the section below ) it calls the 'get_next_action_from_soup'

     while check_for_captcha(login_soup):
     ...
     
        inputs = get_inputs_from_soup(login_soup)
        inputs["guess"] = guess
        inputs["use_image_captcha"] = "true"
        inputs["use_audio_captcha"] = "false"
        inputs["showPasswordChecked"] = "false"
        inputs["email"] = username
        inputs["password"] = password

        method, url = get_next_action_from_soup(login_soup)

inside that method it gets an exception on line 126

method = form["method"]

KeyError: method

The form variable contains the following
(<)form action="get" name="ue_backdetect"(>)<input name="ue_back" type="hidden" value="1"/></form>

Replace (<) with < above

I have used the captcha on many occasions in the past with success until now.

@mkb79
Copy link
Owner

mkb79 commented Nov 29, 2021

Your issue seems to be identical with #72. I think I know what happens. Will look at this at soon as possible!

This was linked to pull requests Nov 30, 2021
@gigs94
Copy link

gigs94 commented Jan 11, 2022

I'm getting this error as well with the latest master branch installed... let me know if you want me to test other branches.

Traceback (most recent call last):
  File "./get_books.py", line 23, in <module>
    auth = audible.auth.Authenticator.from_login(
  File "/usr/local/anaconda3/lib/python3.8/site-packages/audible/auth.py", line 368, in from_login
    login_device = login(
  File "/usr/local/anaconda3/lib/python3.8/site-packages/audible/login.py", line 388, in login
    method, url = get_next_action_from_soup(login_soup)
  File "/usr/local/anaconda3/lib/python3.8/site-packages/audible/login.py", line 126, in get_next_action_from_soup
    method = form["method"]
  File "/usr/local/anaconda3/lib/python3.8/site-packages/bs4/element.py", line 1406, in __getitem__
    return self.attrs[key]
KeyError: 'method'

@mkb79
Copy link
Owner

mkb79 commented Jan 12, 2022

The real problem is not on the captcha page. Audible uses httpx to send requests to the server. Can you enable debug logging for the httpx module and rerun your script? Then you can see, which requests are made and which was the last requested url.

@lmergner
Copy link

lmergner commented Jan 15, 2022

I can't tell if I'm exposing my password or username for audible by sharing this log snippet. Please let me know!

$ pip list | grep audible
audible              0.6.0
$ python --version
Python 3.10.1
DEBUG:httpx._client:HTTP Request: GET https://www.amazon.com/ap/signin?openid.oa2.response_type=code&openid.oa2.code_challenge_method=S256&openid.oa2.code_challenge=HLUpE0u2CScFj38Xb-7_m2y6WKBt442FtdfzO_AjNR0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fap%2Fmaplanding&openid.assoc_handle=amzn_audible_ios_us&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&pageId=amzn_audible_ios&accountStatusPolicy=P1&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns.oa2=http%3A%2F%2Fwww.amazon.com%2Fap%2Fext%2Foauth%2F2&openid.oa2.client_id=device%3A4645324342434537353442463442363942383732384534353432374641373237234132435a4a5a474c4b324a4a564d&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&marketPlaceId=AF2M0KC94RCEA&openid.oa2.scope=device_auth_access&forceMobileLayout=true&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.pape.max_auth_age=0 "HTTP/1.1 200 OK"
DEBUG:httpx._client:HTTP Request: POST https://www.amazon.com/ap/signin/131-0022030-0687802 "HTTP/1.1 200 OK"
ERROR:audible.login:Error message: Important Message! To better protect your account, please re-enter your password and then enter the characters as they are shown in the image below.
DEBUG:httpx._client:HTTP Request: GET https://opfcaptcha-prod.s3.amazonaws.com/86cd0db4957146aabd14628fe047acac.jpg?AWSAccessKeyId=AKIA5WBBRBBB6V2IYVNM&Expires=1642264409&Signature=B4BzOhAAMKWy3lKvRdZmIsJxpk0%3D "HTTP/1.1 200 OK"
Answer for CAPTCHA: n735tx
Traceback (most recent call last):
  File "/Users/lmerg/.pyenv/versions/3.10.1/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/lmerg/.pyenv/versions/3.10.1/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/lmerg/code/abook/abook/__main__.py", line 213, in <module>
    cli()
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/lmerg/code/abook/abook/__main__.py", line 199, in library
    get_audible_library(
  File "/Users/lmerg/code/abook/abook/library.py", line 18, in get_audible_library
    auth = audible.Authenticator.from_login(
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/audible/auth.py", line 368, in from_login
    login_device = login(
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/audible/login.py", line 388, in login
    method, url = get_next_action_from_soup(login_soup)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/audible/login.py", line 126, in get_next_action_from_soup
    method = form["method"]
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/bs4/element.py", line 1486, in __getitem__
    return self.attrs[key]
KeyError: 'method'

@mkb79
Copy link
Owner

mkb79 commented Jan 15, 2022

Don’t worry, there are no username/password in the log. Can you use git and clone the master branch and install it. In my last commit I resolved the KeyError issue.

@lmergner
Copy link

With pip install -U git+https://github.com/mkb79/Audible#egg=audible I get a login error, which is progress of a sort.

[DEBUG] [__main__.py:118@cli] Found ffmpeg version 4.4.1
INFO:audible.login:Login with Amazon Account.
DEBUG:httpx._client:HTTP Request: GET https://www.amazon.com/ap/signin?openid.oa2.response_type=code&openid.oa2.code_challenge_method=S256&openid.oa2.code_challenge=TVCMYcMQ5CP1i0UEHWaYPr0AKDTYDR9IRdz94fRPw8Q&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fap%2Fmaplanding&openid.assoc_handle=amzn_audible_ios_us&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&pageId=amzn_audible_ios&accountStatusPolicy=P1&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns.oa2=http%3A%2F%2Fwww.amazon.com%2Fap%2Fext%2Foauth%2F2&openid.oa2.client_id=device%3A3944323836353835354330463444433438343530464633353935303632333344234132435a4a5a474c4b324a4a564d&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&marketPlaceId=AF2M0KC94RCEA&openid.oa2.scope=device_auth_access&forceMobileLayout=true&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.pape.max_auth_age=0 "HTTP/1.1 200 OK"
DEBUG:httpx._client:HTTP Request: POST https://www.amazon.com/ap/signin/130-0770017-3958167 "HTTP/1.1 200 OK"
ERROR:audible.login:Error message: Important Message! To better protect your account, please re-enter your password and then enter the characters as they are shown in the image below.
DEBUG:httpx._client:HTTP Request: GET https://opfcaptcha-prod.s3.amazonaws.com/3dcfb3954499405f9459a6214a85d777.jpg?AWSAccessKeyId=AKIA5WBBRBBB6V2IYVNM&Expires=1642265498&Signature=fnB8TazoDibzpjY6z%2FMNUpKG6iQ%3D "HTTP/1.1 200 OK"
Answer for CAPTCHA: ghpd48
DEBUG:httpx._client:HTTP Request: GET https://www.amazon.com/get "HTTP/1.1 301 Moved Permanently"
Traceback (most recent call last):
  File "/Users/lmerg/.pyenv/versions/3.10.1/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/lmerg/.pyenv/versions/3.10.1/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/lmerg/code/abook/abook/__main__.py", line 213, in <module>
    cli()
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/lmerg/code/abook/abook/__main__.py", line 199, in library
    get_audible_library(
  File "/Users/lmerg/code/abook/abook/library.py", line 17, in get_audible_library
    auth = audible.Authenticator.from_login(
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/audible/auth.py", line 368, in from_login
    login_device = login(
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/audible/login.py", line 500, in login
    raise Exception("Login failed. Please check the log.")
Exception: Login failed. Please check the log.

I'm enabling debug logging, but I don't see any other logs that I can check.

logger = logging.getLogger(<my_library>)
httpx_logger = logging.getLogger("httpx")
httpx_logger.setLevel(logging.DEBUG)
audible_logger = logging.getLogger("audible.login")
audible_logger.setLevel(logging.DEBUG)

@mkb79
Copy link
Owner

mkb79 commented Jan 15, 2022

Okay. There could be two things which could be cause the error.

  1. There are multiple form tags and the wrong is selected through the function

  2. Audible changes something on the captchas page.

Let me try something.

@mkb79
Copy link
Owner

mkb79 commented Jan 15, 2022

Can you try this repo https://github.com/mkb79/Audible/tree/issue-73 please?! This will print out all forms found on a page. Then I can see if the captcha page contains additional forms.

@lmergner
Copy link

Sorry first time pulling from a github issue. How do I pip install it? I've added the commit hash to the url already.

$ pip install -U git+https://github.com/mkb79/Audible/tree/issue-73@c3823c04659128cbfabefa1a9b4b5046de769584#egg=audible
Collecting audible
  Cloning https://github.com/mkb79/Audible/tree/issue-73 (to revision c3823c04659128cbfabefa1a9b4b5046de769584) to /private/var/folders/tj/sz8275nx2kj4czqq2qsqlwf40000gn/T/pip-install-0q4pgyt_/audible_610ec47cbfed4deb83f56035d369f5b9
  Running command git clone --filter=blob:none -q https://github.com/mkb79/Audible/tree/issue-73 /private/var/folders/tj/sz8275nx2kj4czqq2qsqlwf40000gn/T/pip-install-0q4pgyt_/audible_610ec47cbfed4deb83f56035d369f5b9
  fatal: repository 'https://github.com/mkb79/Audible/tree/issue-73/' not found

@mkb79
Copy link
Owner

mkb79 commented Jan 15, 2022

Best is you clone from github repo this way

git clone --branch issue-73 https://github.com/mkb79/Audible
cd audible-cli
pip install --upgrade .

@lmergner
Copy link

lmergner commented Jan 15, 2022

You know, when you put it like that, I feel very silly.

If it matters, I'm in the "us" marketplace.

INFO:audible.login:Login with Amazon Account.
DEBUG:httpx._client:HTTP Request: GET https://www.amazon.com/ap/signin?openid.oa2.response_type=code&openid.oa2.code_challenge_method=S256&openid.oa2.code_challenge=918f0QmoQ46uNsXbLVLCJsApCUj979KuAjEwjlAcZBw&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fap%2Fmaplanding&openid.assoc_handle=amzn_audible_ios_us&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&pageId=amzn_audible_ios&accountStatusPolicy=P1&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns.oa2=http%3A%2F%2Fwww.amazon.com%2Fap%2Fext%2Foauth%2F2&openid.oa2.client_id=device%3A4537444430323938303335443430343242383746433845303533384531424333234132435a4a5a474c4b324a4a564d&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&marketPlaceId=AF2M0KC94RCEA&openid.oa2.scope=device_auth_access&forceMobileLayout=true&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.pape.max_auth_age=0 "HTTP/1.1 200 OK"
Found 2 on page.
action https://www.amazon.com/ap/signin/141-2438372-0520154
method post

action get
method None

DEBUG:httpx._client:HTTP Request: POST https://www.amazon.com/ap/signin/141-2438372-0520154 "HTTP/1.1 200 OK"
ERROR:audible.login:Error message: Important Message! To better protect your account, please re-enter your password and then enter the characters as they are shown in the image below.
DEBUG:httpx._client:HTTP Request: GET https://opfcaptcha-prod.s3.amazonaws.com/7d9f16fff3f54846a08c37bea024335b.jpg?AWSAccessKeyId=AKIA5WBBRBBB6V2IYVNM&Expires=1642268022&Signature=CP7YLaDrdW1G3ibjy3vTHFnWXVY%3D "HTTP/1.1 200 OK"
Answer for CAPTCHA: zz4vfh
Found 2 on page.
action https://www.amazon.com/ap/signin
method post

action get
method None

DEBUG:httpx._client:HTTP Request: GET https://www.amazon.com/get "HTTP/1.1 301 Moved Permanently"
Traceback (most recent call last):
  File "/Users/lmerg/.pyenv/versions/3.10.1/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/lmerg/.pyenv/versions/3.10.1/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/lmerg/code/abook/abook/__main__.py", line 209, in <module>
    cli()
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/lmerg/code/abook/abook/__main__.py", line 193, in library
    get_audible_library(
  File "/Users/lmerg/code/abook/abook/library.py", line 17, in get_audible_library
    auth = audible.Authenticator.from_login(
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/audible/auth.py", line 368, in from_login
    login_device = login(
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/audible/login.py", line 511, in login
    raise Exception("Login failed. Please check the log.")
Exception: Login failed. Please check the log.

@mkb79
Copy link
Owner

mkb79 commented Jan 15, 2022

Okay, good news. There are two forms and the wrong is selected. Now I need the name of the form (I forget these)! Can you delete the audible-cli folder and repeat the steps above (reinstall issue branch and test)!

With the name of the form I can solve the issue easy

@lmergner
Copy link

INFO:audible.login:Login with Amazon Account.
DEBUG:httpx._client:HTTP Request: GET https://www.amazon.com/ap/signin?openid.oa2.response_type=code&openid.oa2.code_challenge_method=S256&openid.oa2.code_challenge=zKHOHVqgUWbNcvGUfjsCX9fYmwD72EQji7HDNw8TQBE&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fap%2Fmaplanding&openid.assoc_handle=amzn_audible_ios_us&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&pageId=amzn_audible_ios&accountStatusPolicy=P1&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns.oa2=http%3A%2F%2Fwww.amazon.com%2Fap%2Fext%2Foauth%2F2&openid.oa2.client_id=device%3A3739343142323141383742363438464439303942373345394445433145373132234132435a4a5a474c4b324a4a564d&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&marketPlaceId=AF2M0KC94RCEA&openid.oa2.scope=device_auth_access&forceMobileLayout=true&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.pape.max_auth_age=0 "HTTP/1.1 200 OK"
Found 2 on page.
name signIn
action https://www.amazon.com/ap/signin/134-8509596-8066427
method post

name ue_backdetect
action get
method None

DEBUG:httpx._client:HTTP Request: POST https://www.amazon.com/ap/signin/134-8509596-8066427 "HTTP/1.1 200 OK"
ERROR:audible.login:Error message: Important Message! To better protect your account, please re-enter your password and then enter the characters as they are shown in the image below.
DEBUG:httpx._client:HTTP Request: GET https://opfcaptcha-prod.s3.amazonaws.com/374e39ed13254587b3fad9567dbe0a70.jpg?AWSAccessKeyId=AKIA5WBBRBBB6V2IYVNM&Expires=1642268593&Signature=cgnRIC7x2%2BgmhGEk46TaIM9ca5Y%3D "HTTP/1.1 200 OK"
Answer for CAPTCHA: 77sbm2
Found 2 on page.
name signIn
action https://www.amazon.com/ap/signin
method post

name ue_backdetect
action get
method None

DEBUG:httpx._client:HTTP Request: GET https://www.amazon.com/get "HTTP/1.1 403 Forbidden"
Traceback (most recent call last):
  File "/Users/lmerg/.pyenv/versions/3.10.1/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/lmerg/.pyenv/versions/3.10.1/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/lmerg/code/abook/abook/__main__.py", line 209, in <module>
    cli()
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/lmerg/code/abook/abook/__main__.py", line 193, in library
    get_audible_library(
  File "/Users/lmerg/code/abook/abook/library.py", line 17, in get_audible_library
    auth = audible.Authenticator.from_login(
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/audible/auth.py", line 368, in from_login
    login_device = login(
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/audible/login.py", line 513, in login
    raise Exception("Login failed. Please check the log.")
Exception: Login failed. Please check the log.

@mkb79
Copy link
Owner

mkb79 commented Jan 15, 2022

I think I solved the issue now. Can you repeat your last step again (pull and reinstall)!

@lmergner
Copy link

INFO:audible.login:Login with Amazon Account.
DEBUG:httpx._client:HTTP Request: GET https://www.amazon.com/ap/signin?openid.oa2.response_type=code&openid.oa2.code_challenge_method=S256&openid.oa2.code_challenge=FcBhcrZENqJWfjDH5EBMVFffwJsS9teyntIRB7rFSig&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fap%2Fmaplanding&openid.assoc_handle=amzn_audible_ios_us&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&pageId=amzn_audible_ios&accountStatusPolicy=P1&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns.oa2=http%3A%2F%2Fwww.amazon.com%2Fap%2Fext%2Foauth%2F2&openid.oa2.client_id=device%3A3245463630423136323434313433324541333043354337394246384637423231234132435a4a5a474c4b324a4a564d&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&marketPlaceId=AF2M0KC94RCEA&openid.oa2.scope=device_auth_access&forceMobileLayout=true&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.pape.max_auth_age=0 "HTTP/1.1 200 OK"
Found 2 on page.
name signIn
action https://www.amazon.com/ap/signin/136-0651603-2148857
method post

name ue_backdetect
action get
method None

DEBUG:httpx._client:HTTP Request: POST https://www.amazon.com/ap/signin/136-0651603-2148857 "HTTP/1.1 200 OK"
ERROR:audible.login:Error message: Important Message! To better protect your account, please re-enter your password and then enter the characters as they are shown in the image below.
DEBUG:httpx._client:HTTP Request: GET https://opfcaptcha-prod.s3.amazonaws.com/14b4cc1acab94a9fb467b8fa49f22bc8.jpg?AWSAccessKeyId=AKIA5WBBRBBB6V2IYVNM&Expires=1642268940&Signature=3cpTvS2%2BR8Pwen%2FEtire5AB%2BneE%3D "HTTP/1.1 200 OK"
Answer for CAPTCHA: 7v6n6n
Found 2 on page.
name signIn
action https://www.amazon.com/ap/signin
method post

name ue_backdetect
action get
method None

DEBUG:httpx._client:HTTP Request: POST https://www.amazon.com/ap/signin "HTTP/1.1 200 OK"
ERROR:audible.login:Error message: There was a problem Enter the characters as they are given in the challenge.
DEBUG:httpx._client:HTTP Request: GET https://opfcaptcha-prod.s3.amazonaws.com/225239f2755b4436a8ede486e6da5e84.jpg?AWSAccessKeyId=AKIA5WBBRBBB6V2IYVNM&Expires=1642268963&Signature=ZJ5zbCTu2X04z%2F%2Bkuz3jEzb2qwQ%3D "HTTP/1.1 200 OK"
Answer for CAPTCHA: znws6t
Found 2 on page.
name signIn
action https://www.amazon.com/ap/signin
method post

name ue_backdetect
action get
method None

DEBUG:httpx._client:HTTP Request: POST https://www.amazon.com/ap/signin "HTTP/1.1 200 OK"
ERROR:audible.login:Error message: There was a problem Enter the characters as they are given in the challenge.
DEBUG:httpx._client:HTTP Request: GET https://opfcaptcha-prod.s3.amazonaws.com/0d338f4f867b4949b0378cafc5b9c98e.jpg?AWSAccessKeyId=AKIA5WBBRBBB6V2IYVNM&Expires=1642268979&Signature=vSjCheLlCEVh4qS%2FKDIyzMBovbg%3D "HTTP/1.1 200 OK"
Answer for CAPTCHA: 362w5w
Found 2 on page.
name signIn
action https://www.amazon.com/ap/signin
method post

name ue_backdetect
action get
method None

DEBUG:httpx._client:HTTP Request: POST https://www.amazon.com/ap/signin "HTTP/1.1 302 Moved Temporarily"
Traceback (most recent call last):
  File "/Users/lmerg/.pyenv/versions/3.10.1/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/lmerg/.pyenv/versions/3.10.1/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/lmerg/code/abook/abook/__main__.py", line 209, in <module>
    cli()
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/lmerg/code/abook/abook/__main__.py", line 193, in library
    get_audible_library(
  File "/Users/lmerg/code/abook/abook/library.py", line 17, in get_audible_library
    auth = audible.Authenticator.from_login(
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/audible/auth.py", line 368, in from_login
    login_device = login(
  File "/Users/lmerg/.pyenv/versions/abook/lib/python3.10/site-packages/audible/login.py", line 513, in login
    raise Exception("Login failed. Please check the log.")
Exception: Login failed. Please check the log.

@mkb79
Copy link
Owner

mkb79 commented Jan 15, 2022

I have committed changes. Can you try them. These should solve the new issue.

@lmergner
Copy link

Looks good. Thanks for the fix. I can't imagine how hard it is to keep up with unofficial API changes.

INFO:audible.login:Login with Amazon Account.
DEBUG:httpx._client:HTTP Request: GET https://www.amazon.com/ap/signin?openid.oa2.response_type=code&openid.oa2.code_challenge_method=S256&openid.oa2.code_challenge=e018z4IlZgJkAJ1uFjVpBVUz6RRGZ-0lkoFCteQqDxE&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fap%2Fmaplanding&openid.assoc_handle=amzn_audible_ios_us&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&pageId=amzn_audible_ios&accountStatusPolicy=P1&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns.oa2=http%3A%2F%2Fwww.amazon.com%2Fap%2Fext%2Foauth%2F2&openid.oa2.client_id=device%3A4441303738414636453338353430333639394430373246374531453432313635234132435a4a5a474c4b324a4a564d&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&marketPlaceId=AF2M0KC94RCEA&openid.oa2.scope=device_auth_access&forceMobileLayout=true&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.pape.max_auth_age=0 "HTTP/1.1 200 OK"
Found 2 on page.
name signIn
action https://www.amazon.com/ap/signin/133-3796299-2950524
method post

name ue_backdetect
action get
method None

DEBUG:httpx._client:HTTP Request: POST https://www.amazon.com/ap/signin/133-3796299-2950524 "HTTP/1.1 200 OK"
ERROR:audible.login:Error message: Important Message! To better protect your account, please re-enter your password and then enter the characters as they are shown in the image below.
DEBUG:httpx._client:HTTP Request: GET https://opfcaptcha-prod.s3.amazonaws.com/a7a651a91a9840b29bfa324fba373e35.jpg?AWSAccessKeyId=AKIA5WBBRBBB6V2IYVNM&Expires=1642270846&Signature=%2Bt6qLQ4tbSsLDi9rwIWX08f5b%2B0%3D "HTTP/1.1 200 OK"
Answer for CAPTCHA: t727s6
Found 2 on page.
name signIn
action https://www.amazon.com/ap/signin
method post

name ue_backdetect
action get
method None

DEBUG:httpx._client:HTTP Request: POST https://www.amazon.com/ap/signin "HTTP/1.1 302 Found"
DEBUG:httpx._client:HTTP Request: GET https://www.amazon.com/ap/challenge?ie=UTF8&arb=228efbd8-6699-495e-b9ad-0cd945cabd76 "HTTP/1.1 302 Found"
DEBUG:httpx._client:HTTP Request: GET https://www.amazon.com/ap/cvf/approval?arb=978303a6-2084-493c-a188-d8d28d042902&openid.assoc_handle=amzn_audible_ios_us&pageId=amzn_audible_ios&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fap%2Fsignin%3Fie%3DUTF8%26clientContext%3D132-8462583-4005936%26openid.pape.max_auth_age%3D0%26use_global_authentication%3Dfalse%26forceMobileLayout%3Dtrue%26accountStatusPolicy%3DP1%26openid.identity%3Dhttp%253A%252F%252Fspecs.openid.net%252Fauth%252F2.0%252Fidentifier_select%26use_audio_captcha%3Dfalse%26marketPlaceId%3DAF2M0KC94RCEA%26pageId%3Damzn_audible_ios%26arb%3Da9ffeeb9-a208-4ab3-b31c-feac2504b09f%26openid.return_to%3Dhttps%253A%252F%252Fwww.amazon.com%252Fap%252Fmaplanding%26openid.assoc_handle%3Damzn_audible_ios_us%26openid.oa2.response_type%3Dcode%26openid.mode%3Dcheckid_setup%26openid.ns.pape%3Dhttp%253A%252F%252Fspecs.openid.net%252Fextensions%252Fpape%252F1.0%26openid.ns.oa2%3Dhttp%253A%252F%252Fwww.amazon.com%252Fap%252Fext%252Foauth%252F2%26openid.oa2.code_challenge_method%3DS256%26openid.oa2.code_challenge%3De018z4IlZgJkAJ1uFjVpBVUz6RRGZ-0lkoFCteQqDxE%26openid.oa2.scope%3Ddevice_auth_access%26openid.claimed_id%3Dhttp%253A%252F%252Fspecs.openid.net%252Fauth%252F2.0%252Fidentifier_select%26openid.oa2.client_id%3Ddevice%253A4441303738414636453338353430333639394430373246374531453432313635234132435a4a5a474c4b324a4a564d%26openid.ns%3Dhttp%253A%252F%252Fspecs.openid.net%252Fauth%252F2.0 "HTTP/1.1 200 OK"
Approval alert detected! Amazon sends you a mail.
Please press ENTER when you approve the notification.

@mkb79 mkb79 linked a pull request Jan 15, 2022 that will close this issue
@mkb79 mkb79 closed this as completed in #80 Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants