Audible icon indicating copy to clipboard operation
Audible copied to clipboard

Is there any way to do async login?

Open anderspitman opened this issue 1 year ago • 12 comments

I'm trying to integrate this library into a BeeWare GUI app, and having async issues. I suspect it's because from_login is synchronous. Is there any way to perform async login, or is there perhaps another cause of my problem?

anderspitman avatar Apr 22 '25 17:04 anderspitman

@anderspitman

I've created the branch https://github.com/mkb79/Audible/tree/issue/make-login-async. Can you try it out and report back?!

Edit: I wrote the code with my iPhone and does not verified it. But it should work.

mkb79 avatar Apr 23 '25 08:04 mkb79

Wow that was quick thank you!

It's almost working. I just needed to await otp_callback for my code to work:

https://github.com/mkb79/Audible/blob/2e4390fca307a03259365316b31bcd05e8d0e6b0/src/audible/login.py#L488

anderspitman avatar Apr 23 '25 16:04 anderspitman

Wow that was quick thank you!

It's almost working. I just needed to await otp_callback for my code to work:

Audible/src/audible/login.py

Line 488 in 2e4390f

otp_code = otp_callback()

Good to hear that! You are using your own otp callback function? Then yes, this must be awaited too.

mkb79 avatar Apr 23 '25 16:04 mkb79

Yeah custom otp_callback because I'm showing an input dialog to the user if the OTP is triggered. I'll likely need to do the same for the other callbacks

anderspitman avatar Apr 23 '25 16:04 anderspitman

Yeah custom otp_callback because I'm showing an input dialog to the user if the OTP is triggered. I'll likely need to do the same for the other callbacks

Ah, okay. I doesn't know that. Than you have to await your other custom callbacks in the login function too, if they are coroutines/Awaitables.

mkb79 avatar Apr 23 '25 16:04 mkb79

Is there a way to implement it in your library so that it works whether the user provides a sync or async callback? Not sure if that's possible in Python

anderspitman avatar Apr 23 '25 18:04 anderspitman

@anderspitman Only the login function needs packages like beautifulsoup or pillow. So I've tinking about outsourcing the login and register function in a separate package. This way the main package needs less dependencies. Then I can implement sync and async functions without overhaul the main package.

mkb79 avatar May 12 '25 16:05 mkb79

This issue has not been updated for a while and will be closed soon.

github-actions[bot] avatar Jul 12 '25 03:07 github-actions[bot]

This issue has automatically been closed due to no activities.

github-actions[bot] avatar Jul 22 '25 03:07 github-actions[bot]

@mkb79 is this still planned eventually?

anderspitman avatar Jul 22 '25 03:07 anderspitman

This issue has not been updated for a while and will be closed soon.

github-actions[bot] avatar Sep 22 '25 03:09 github-actions[bot]

This issue has automatically been closed due to no activities.

github-actions[bot] avatar Oct 03 '25 03:10 github-actions[bot]