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

Fixed login with --cred got hang #350

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

821wkli
Copy link

@821wkli 821wkli commented Oct 15, 2023

#346

This is the migration of IOS app login

@r0ssing
Copy link

r0ssing commented Oct 23, 2023

Thank you @821wkli !

@julio213180
Copy link

#346

This is the migration of IOS app login

thank you, it is working again

@owen800q
Copy link

Thank you, it works

@jacknashg
Copy link

it works, save my day. thank you!

@akipham15
Copy link

Thanks

@timchenko-a
Copy link

Is it still working for you?
I'm getting some error when trying to login (https://github.com/821wkli/safaribooks/blob/login_fix/safaribooks.py#L477-L488)

[#] Unhandled Exception: Expecting value: line 1 column 1 (char 0) (type: JSONDecodeError)

If I add print(response.text) just before trying to decode as JSON I can see the next body:

<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>

You don't have permission to access "http&#58;&#47;&#47;api&#46;oreilly&#46;com&#47;api&#47;v1&#47;auth&#47;login&#47;" on this server.<P>
Reference&#32;&#35;18&#46;8b7a7b5c&#46;1708962162&#46;62e9acfa
</BODY>
</HTML>

@jacknashg
Copy link

not working anymore. refer #351 for manual walk around.

Is it still working for you? I'm getting some error when trying to login (https://github.com/821wkli/safaribooks/blob/login_fix/safaribooks.py#L477-L488)

[#] Unhandled Exception: Expecting value: line 1 column 1 (char 0) (type: JSONDecodeError)

If I add print(response.text) just before trying to decode as JSON I can see the next body:

<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>

You don't have permission to access "http&#58;&#47;&#47;api&#46;oreilly&#46;com&#47;api&#47;v1&#47;auth&#47;login&#47;" on this server.<P>
Reference&#32;&#35;18&#46;8b7a7b5c&#46;1708962162&#46;62e9acfa
</BODY>
</HTML>

@mhughdo
Copy link

mhughdo commented Mar 9, 2024

not working anymore. refer #351 for manual walk around.

Is it still working for you? I'm getting some error when trying to login (https://github.com/821wkli/safaribooks/blob/login_fix/safaribooks.py#L477-L488)

[#] Unhandled Exception: Expecting value: line 1 column 1 (char 0) (type: JSONDecodeError)

If I add print(response.text) just before trying to decode as JSON I can see the next body:

<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>

You don't have permission to access "http&#58;&#47;&#47;api&#46;oreilly&#46;com&#47;api&#47;v1&#47;auth&#47;login&#47;" on this server.<P>
Reference&#32;&#35;18&#46;8b7a7b5c&#46;1708962162&#46;62e9acfa
</BODY>
</HTML>

Note: After setting the cookies.json file manually, run python3 safaribooks.py bookID without --cred "xx:xx"

@teticio
Copy link

teticio commented Mar 22, 2024

What I find works for me is to

pip install browser_cookie3

add

import browser_cookie3

to safaribooks.py and change

        if not args.cred:
            if not os.path.isfile(COOKIES_FILE):
                self.display.exit("Login: unable to find `cookies.json` file.\n"
                                  "    Please use the `--cred` or `--login` options to perform the login.")

            self.session.cookies.update(json.load(open(COOKIES_FILE)))

to

        if not args.cred:
            # if not os.path.isfile(COOKIES_FILE):
            #     self.display.exit("Login: unable to find `cookies.json` file.\n"
            #                       "    Please use the `--cred` or `--login` options to perform the login.")

            # self.session.cookies.update(json.load(open(COOKIES_FILE)))
            self.session.cookies.update(browser_cookie3.chrome())

Then, if I log in using Chome and run the script without providing credentials, it works.

@kastuin
Copy link

kastuin commented Apr 8, 2024

thank you @teticio, worked for me.

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.

None yet

10 participants