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

Fix 403 authorization errors #128

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Fix 403 authorization errors #128

wants to merge 3 commits into from

Conversation

Teuns
Copy link

@Teuns Teuns commented Nov 20, 2024

Probably related: #127

For some reason the authentication process returns 403 errors all of a sudden. I think this is due to CloudFlare blocking the requests automatically. This branch solves it by using urllib instead of requests in the specific faulty requests, as pointed out in a StackOverflow post](https://stackoverflow.com/a/74674276).

kobodl/kobo.py Outdated
Comment on lines 532 to 535
def get_cookie_value(cookie_name):
if cookie_name in cookie:
return cookie[cookie_name].value
return None
Copy link

@lubomir-brindza lubomir-brindza Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This closure is never called; did you mean to leave this in here?

e: Looking at this some more, there's some redundant code here; this whole block (529-543) seems like it's a leftover and no longer necessary

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! That definitely shouldn't be in here. I'll delete it

@lubomir-brindza
Copy link

lubomir-brindza commented Nov 21, 2024

I can confirm that this PR does fix the login issue for me, nice work :)

@subdavis apologies for barging in here, I just know from the related issues that you're not affected / able to reproduce this

@@ -166,7 +184,7 @@ def __GetExtraLoginParameters(self) -> Tuple[str, str, str]:
)
requestVerificationToken = html.unescape(match.group(1))

return koboSignInUrl, workflowId, requestVerificationToken
return koboSignInUrl, workflowId, requestVerificationToken, authCookie

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to update the return type for __GetExtraLoginParameters to Tuple[str, str, str, str]

@bybpow
Copy link

bybpow commented Nov 21, 2024

Please merge this soon. I reseted my account and now I can't add a user or download. Thanks for your work.

@chewi
Copy link

chewi commented Nov 21, 2024

This doesn't seem to fix it for me, but I'm seeing it on the download request.

requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://storedownloads.kobo.com/download?downloadToken=XXXXXXXX

@subdavis
Copy link
Owner

Thanks everyone for your involvement in this fix. I'll get this merged and released later this evening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants