audiamus / BookLibConnect

A standalone Audible downloader and decrypter
GNU General Public License v3.0
701 stars 40 forks source link

Device registration fails #36

Closed 2001db8 closed 2 years ago

2001db8 commented 2 years ago

Hi,

I've just installed v0.6 and try to register the app using my pre-Amazon account. When I open the created login URL and log in I'll have to reenter my password and solve a captcha "for better protection" but when I then copy the "Cannot find page" URL into BookLib it says "Device registration failed"

Is there any way I can debug this any further? Pasword is correct (tried a false password to see the difference) and the "Cannot find page" URL looks like the login was successfull. Has auth codes, captcha verified and so on. Could this be because there are already too many devices registered (if there is a limit)? Deauthorized iTunes and tried again, same error.

Best regards

Jens

audiamus commented 2 years ago

Does the log file reveal more information? You may need to set the log level to 4. There will also be a few files in tmp directory, related to the API calls.

2001db8 commented 2 years ago

From the log:

[...]
  WWW-Authenticate = Basic realm="api.amazon.de/auth/register", error="CredentialError", error_description="The input credential is invalid."
  Cache-Control = no-store, must-revalidate, no-cache
  x-amzn-Remapped-WWW-Authenticate = Basic realm="api.amazon.de/auth/register", error="CredentialError", error_description="The input credential is invalid."
18:20:25.929 0001 [Authorize.RegisterAsync] HttpRequestException: "Response status code does not indicate success: 401 (Unauthorized)."
[...]

The credentials are correct, otherwise I would not reach the "Cannot find page" URL but a "wrong password" warning and stay on the captcha page.

From the temp files I gather the App tries to register as an iPhone. I have 5 mobile devices registered with Audible, so according to https://hilfe.audible.de/s/article/geraeteanzahl-audible-konto there should be room for another one.

I'll do more testing tomorrow and deauth some of my mobile devices. Schoenen Feierabend :)

audiamus commented 2 years ago

You could also try https://github.com/mkb79/audible-cli which is more or less seen as the reference client implementation for the Audible API. If that works, then there is a good chance we can make it work for Book Lib Connect as well.

mkb79 commented 2 years ago

Hi. I‘m think that it would fail for audible-cli too. If you login with username, the registration url must be https://api.audible.{domain}/auth/register instead of https://api.amazon.{domain}/auth/register.

2001db8 commented 2 years ago

audible-cli tells me Login was successful. Now registering a new device. but then runs into an exception: 'message': 'The server has encountered a runtime error.' I still think this might be due to too many devices registered to my account. I'll try to deauth an old iPhone tomorrow and see if that helps. Maybe contact support and get a listing of registered devices.

Thanks for your help so far!

mkb79 commented 2 years ago

@2001db8 You don’t have to many devices. The issue is the wrong domain for the registration url. If you login with a pre-Amazon account the domain must be audible and not amazon for device registration after successfully login!

audiamus commented 2 years ago

If you login with username, the registration url must be https://api.audible.{domain}/auth/register

Excellent, thank you. I was always wondering whether the registration address might have to be different, too.

I'll modify it in my code.

mkb79 commented 2 years ago

I‘ve updated audible-cli. Login with pre-Amzon account should work now!

audiamus commented 2 years ago

Can you give it another try : Version 0.7 ? I have modified the registration URL for a pre-Amazon account but since I do not have such an account I can't test this myself.

2001db8 commented 2 years ago

Can you give it another try : Version 0.7 ? I have modified the registration URL for a pre-Amazon account but since I do not have such an account I can't test this myself.

Still not working. URLs seem to be all pointing to https://api.audible.de/auth/register but then it throws an error:

15:47:30.415 0001 [Authorize.RegisterAsync] Before request, POST, https://api.audible.de/auth/register
15:47:30.416 0001 [Authorize.RegisterAsync] Before request, HttpRequestHeaders:
  Accept = application/json
15:47:31.228 0001 [Authorize.RegisterAsync] After request,  POST, status=OK, requestUri=https://api.audible.de/auth/register
15:47:31.229 0001 [Authorize.RegisterAsync] After request,  HttpResponseHeaders:
  Server = Server
  Date = Sun, 03 Apr 2022 13:47:32 GMT
  Connection = keep-alive
  x-amz-rid = xxxx
  x-amzn-RequestId = xxxx
  X-Amz-Date = Sun, 03 Apr 2022 13:47:32 GMT
  Cache-Control = no-store, must-revalidate, no-cache
  Pragma = no-cache
  Vary = Content-Type
  Vary = Accept-Encoding
  Vary = X-Amzn-CDN-Cache
  Vary = X-Amzn-AX-Treatment
  Vary = User-Agent
  Permissions-Policy = interest-cohort=()
15:47:31.261 0001 [Authorize.updateProfile] NullReferenceException: "Object reference not set to an instance of an object."
15:47:31.261 0001 [Authorize.RegisterAsync] <<< 
15:47:31.262 0001 [AudibleClient.ConfigParseExternalLoginResponseAsync] <<< 
15:47:31.262 0001 [NewProfileForm.textBox2_TextChanged] result=registrationFailed
audiamus commented 2 years ago

This is too bad. The json reply to the registration request appears to be structured differently. And that's ugly because it contains sensitive data. I would need your help here. Below you'll find version 0.7.0.1, for testing purposes only.

I have made two modifications:

  1. The app writes the registration response to the tmp folder: "registration-date.json"
  2. The exception now also writes the line number to the log file.

I am afraid, though, that the line number alone will not suffice. Therefore I need that json response. What you could do is to send it to me as a personal message attachment via reddit.com. My user name there is also "audiamus" (And all my postings are about AAX Audio Converter or Book Lib Connect). Before you do that, remove all text in the value fields in that json file that have names, keys, ids or tokens. (I recommend Visual Studio Code for editing json files as it has the nice feature of formatting compact json to a readable layout: Ctrl+A, then Ctrl+K followed by Ctrl+F) But I need the entire json structure to figure out the differences. You can also deregister your newly registered device with your Amazon account, so any tokens and keys will become useless.

[BookLibConnect-0.7.0.1.zip] Edit: Please use version 0.8 for the diagnostics.

audiamus commented 2 years ago

I have made it easier for you: Version 0.7.0.2 writes a second version of the registration response with all string values replaced by dummy strings: "registration(empty)-date.json". So, no more sensitive data in that one.

[BookLibConnect-0.7.0.2.zip] Edit: Please use version 0.8 for the diagnostics.

CharlesW2506 commented 2 years ago

Trying the above BookLibConnect-0.7.0.2.zip too and the url generated gets me to a login page fine but once I enter the correct amazon credentials it throws an error:

We're sorry. The Web address you entered is not a functioning page on our site.

I'm in the UK and picking the United Kingdom region/domain in the app?

audiamus commented 2 years ago

Now, this is the expected behaviour. Your login was successful, despite the misleading message. You have to copy the URL of that page "We're sorry. The Web address you entered is not a functioning page on our site." into the text box of the New Profile window of Book Lib Connect. This URL is special, not just a "404" wrapper. It contains all the goodies that will allow you the access to your Audible library.

The text box caption, the tool tip or the manual would have given you the hint.

CharlesW2506 commented 2 years ago

Thanks yeah I ended up using the audible-cli to do it which prompted/explained that part, rtfm basically! ha Cheers

audiamus commented 2 years ago

Version 0.8 will write the json response to the tmp folder. This version replaces versions 0.7.0.1 and 0.7.0.2. It does not yet solve the issue, though, for which I need more information. It only simplifies diagnostics.

Tmp folder: C:\Users\<USER>\AppData\Local\audiamus\BookLibConnect\tmp