kaiwk / leetcode.el

An Emacs LeetCode client.
GNU General Public License v3.0
396 stars 70 forks source link

login failed #46

Closed v2gt closed 4 years ago

v2gt commented 4 years ago

.emacs.d/elpa/leetcode-20191011.800/leetcode.el: ‘if-let’ is an obsolete macro (as of 26.1); use ‘if-let*’ instead. [8 times] Contacting host: leetcode.com:443 [2 times] LeetCode login failed: (error http 403) Contacting host: leetcode.com:443

kaiwk commented 4 years ago

Now LeetCode uses reCAPTCHA. We can't login without recaptcha_token. I'm afraid they may add more login authentication from now on.

kaiwk commented 4 years ago

same problem here: https://github.com/skygragon/leetcode-cli/issues/196

cole-jacobs commented 4 years ago

So is there any workaround for this issue? I just installed this package today, and I'm having the same problem logging in.

gopakumar commented 4 years ago

same problem here: skygragon/leetcode-cli#196

they fixed it using login with cookie

gopakumar commented 4 years ago

is there any way to workaround it by using cookie

rockyzhang24 commented 4 years ago

Any updates for this?

kaiwk commented 4 years ago

yes, It seems we can read chrome cookie from local directory and decrypt browser storage, so that we don't need login anymore.

https://github.com/skygragon/leetcode-cli-plugins/blob/master/plugins/cookie.chrome.js

I haven't look into it, but it maybe doable in Emacs too.

rockyzhang24 commented 4 years ago

@kaiwk Thank you very much. Are you planning to implement that?

kaiwk commented 4 years ago

Sure

rockyzhang24 commented 4 years ago

@kaiwk Awesome. Looking forward to it!!!!!! I am new to Emacs, so I am not able to make some contribution to this. I am now already addicted to using this powerful monster. It is the must-have for me to play with LeetCode. Hope it can be fixed soon. Happy 2020.

kaiwk commented 4 years ago

I fix this by using a Python3 script to decrypt Chrome cookies, since Emacs lisp lack crypto library such as PBKDF2.

some things should be aware of:

hope someone confirm it works on Mac, thank you!

rockyzhang24 commented 4 years ago

That's awesome and the best news I got in this new year. I will give it a shot when I go back home later today. Thank you!!!!

rockyzhang24 commented 4 years ago

Hello @kaiwk , I just tried it and I still could not log in. After executing M-x leetcode, there was a progress bar on the status bar and the progress bar kept moving from left to right, and nothing happened. I uploaded a record for you to take a look. Thanks.

By the way, my system is macOS 10.15.2.

kaiwk commented 4 years ago

Hello @kaiwk , I just tried it and I still could not log in. After executing M-x leetcode, there was a progress bar on the status bar and the progress bar kept moving from left to right, and nothing happened. I uploaded a record for you to take a look. Thanks.

By the way, my system is macOS 10.15.2.

have you tried my_cookies in bash? It should ask for Mac OSX keychain password, after that it will print your LEETCODE_SESSION and csrftoken.

if it works, try to eval (executable-find "my_cookies"), it should return the path.

rockyzhang24 commented 4 years ago

It works!!!!! Thank you very much.

jiaming-shi commented 4 years ago

Any progress with Linux and Firefox support? I found there is a python package, browser_cookie3, can extract cookies from web browsers with support for Chrome and Firefox on Linux, Mac and Windows.

yiufung commented 4 years ago

Seconded Linux and Firefox support. I tried with browser_cookie3, it's quite straight-forward and I can test it successfully under Linux/Firefox. It would be greatly appreciated if you may take a look and see if it's easy to integrate.

kaiwk commented 4 years ago

@RicardoMing @yiufung I have update my_cookies, now it has browser_cookie3 as dependency, you can upgrade it by pip install --upgrade my_cookies. Make sure you use 0.1.1 version(it doesn't have --version flag though...), because if you use pypi mirror, it may not update yet.

yiufung commented 4 years ago

Works now with my_cookies v0.1.1 and leetcode v0.10.0. Many thanks for the prompt update!

codeofdusk commented 4 years ago

I still get a LeetCode fetch user and problems failed: (error connection-failed "connect" :host "leetcode.com" :service 443). Emacs can find the location of my_cookies (the eval worked) and my_cookies in terminal prints out my Leetcode session tokens. MacOS 10.15.2, Emacs 26.3.

rockyzhang24 commented 4 years ago

@codeofdusk Try to close your Chrome completely by cmd-q and then restart the Chrome and login Leetcode again.

codeofdusk commented 4 years ago

Sadly still not working.

rockyzhang24 commented 4 years ago

@codeofdusk Okay. On my side, it works very well. MacOS 10.15.2, GNU Emacs 26.3 (installed via "brew install emacs-plus")

codeofdusk commented 4 years ago

@codeofdusk Okay. On my side, it works very well. MacOS 10.15.2, GNU Emacs 26.3 (installed via "brew install emacs-plus")

Got it working via a Linux VM with Firefox for login.

Thanks for making this – I'm totally blind and the Leetcode site doesn't read very well with my screen reader, but it works perfectly under Emacspeak.