kaiwk / leetcode.el

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

Got user is not authenticated while execute leetcode-try #104

Open BWbwchen opened 2 years ago

BWbwchen commented 2 years ago

I got 'use is not authenticated' when I try to execute my code. Below is the output message:

HTTP/1.1 403 Forbidden
Date: Sun, 22 May 2022 11:36:09 GMT
Content-Type: application/json
Content-Length: 38
Connection: keep-alive
x-frame-options: DENY
vary: Cookie
strict-transport-security: max-age=31536000; includeSubDomains; preload
CF-Cache-Status: DYNAMIC
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=BL8w9G4K70%2BHlKXW42IlBckyC71hC5XpAJsHmho6WEPHsMij%2Fe4nThfQdu%2B0m%2FKiaOh7IlEry6%2FTefdQe86zWo%2BBJzn2HozBKhkZyLFJb2oFzKTqVbEnWmuklZCGEQ%3D%3D"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
X-Content-Type-Options: nosniff
Server: cloudflare
CF-RAY: 70f540a3ce838a50-NRT

{"error": "User is not authenticated"}

Could anyone kindly help me? Thx.

kaiwk commented 2 years ago

You need to install my-cookies and make sure Emacs inherit PATH variable, so that Emacs can find my_cookies. You can test it with eshell or eval (executable-find "my_cookies").

You also need to login leetcode.com in Firefox/Chrome first, my_cookies will retrieve leetcode.com cookies from these browsers.

Related issues: https://github.com/kaiwk/leetcode.el/issues/72, https://github.com/kaiwk/leetcode.el/issues/46

YorkZ commented 2 years ago

I'm having this issue as well. I use Arch Linux, and installed leetcode.el through straight.el. I also verified that (executable-find "my_cookies") returned the correct path. I logged in leetcode web interface in both Firefox and chromium.

BWbwchen commented 2 years ago

I solve the problem by login the leetcode.com from the brave web browser. Maybe you can try it.

YorkZ commented 2 years ago

Thanks @BWbwchen, I just installed the brave browser and tried this functionality, and it worked. Thank you.

aljab012 commented 1 year ago
harryaskham commented 1 year ago

Huh, am logged in in Chrome, Firefox and Brave, and running my_cookies on CLI shows the token.

The top of the debug log shows

22:23:18 [DEBUG] login session: redacted
22:23:18 [DEBUG] login csrftoken: redacted
22:23:21 [DEBUG] set user: , solved 0 in 2552 problems
...[problem list]

but the redacted tokens look good. Was working yesterday.

swisstackle commented 1 year ago

Same problem. I use firefox This is the output when I execute $ my_cookies in the terminal:

get cookie from Chrome failed
get cookie from Chromium failed
get cookie from Brave failed
get cookie from Firefox failed
get cookie from Microsoft Edge failed

I re logged in several time in firefox.

Seems like an issue with my_cookies's functionality in combo with firefox.

Update

I installed brave and logged into leetcode on there but the output of $ my_cookies stays the same.

Yuanda-Dong commented 1 year ago

I'm on arch linux. I've got my_cookies to return the LEETCODE_SESSION and csrftoken, but when i tried to submit it still says user is not authenticated.

You probably will get this error when you try to run browser_cookie on arch. I added a None to the function call, and it worked.

File "/home/me/.local/lib/python3.10/site-packages/browser_cookie3/__init__.py", line 245, in get_password return self.__methods_map.get('kwallet')(os_crypt_name) TypeError: _LinuxPasswordManager.__get_kdewallet_password_jeepney() missing 1 required positional argument: 'key'

mrunhap commented 1 year ago

Is there a way I can set cookie manually ?

IsakFalk commented 2 months ago

For this to work I needed to run FF in a new fresh profile without any extensions. I think the privacy extensions may have interfered with the way leetcode.el interacts with the browser.