lorenzodifuccia / safaribooks

Download and generate EPUB of your favorite books from O'Reilly Learning (aka Safari Books Online) library.
Do What The F*ck You Want To Public License
4.61k stars 684 forks source link

Fixed login with --cred got hang #350

Open 821wkli opened 11 months ago

821wkli commented 11 months ago

346

This is the migration of IOS app login

r0ssing commented 10 months ago

Thank you @821wkli !

julio213180 commented 10 months ago

346

This is the migration of IOS app login

thank you, it is working again

owen800q commented 10 months ago

Thank you, it works

jacknashg commented 10 months ago

it works, save my day. thank you!

akipham15 commented 8 months ago

Thanks

timchenko-a commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

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 commented 5 months ago

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 commented 5 months ago

thank you @teticio, worked for me.