kaiwk / leetcode.el

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

leetcode login problem #92

Open jason--liu opened 2 years ago

jason--liu commented 2 years ago

Hi, first of all thanks for your great package. Recently leetcode seems has changed its login mechanism. When try to execute leetcode-try or leetcode-submit, the error message below

HTTP/1.1 403 Forbidden
Date: Thu, 26 Aug 2021 11:28:20 GMT
Content-Type: application/json
Content-Length: 38
Connection: keep-alive
X-Frame-Options: DENY
Vary: Cookie
Set-Cookie: LEETCODE_SESSION=""; Domain=.leetcode.com; expires=Thu, 01 Jan 1970 00:00:00 GMT; Max-Age=0; Path=/; SameSite=Lax
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=PyJPhKpOOoh8GoZgW2D1re9%2FLqeA8vR9249m0pWMxXjRX3n3tLhjymhWqeaTlTfuTrVCg4K9j1WGAkf1xwrLwfG6ho1Se7xIwe2m3elbSaFqzavBeXsON3qdw8R6og%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: 684cb74fcda730d4-SEA

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

Is there any way to fix or workaround this issue? Thank you.

kaiwk commented 2 years ago

I can see LEETCODE_SESSION="", maybe that's the problem here?

You need to make sure you've logged in leetcode.com using Chrome or Firefox recently, so that Emacs can retrieve the cookies from leetcode.com.

KngZhi commented 2 years ago

I was encountered the same problem, here is what I did:

  1. at the terminal using command $ my_cookies to check a) whether the package installed and b) the cookies can be normally accessed, the ideal result would print your LEETCODE_SESSION and csrftoken
  2. if the terminal print get cookie failed, then check a) whether login in the Leetcode or b) did you turn off the cookie option of your chrome, here is link for how to turn on the cookie setting for Chrome.

你的 Session 没东西,说明 emacs 没拿到 cookie 里的东西。你要检查一下浏览器的设置以及你是不是登录了 leetcode.

我之前为了隐私安全禁止了跨三方 cookie 的使用和保存所以在终端执行 my_cookies 总是拿不到值。

lamduong33 commented 2 years ago

my_cookies was not installed by the package for me. Simply installing my_cookies via pip solved this problem for me.