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

Unable to login, CSRF verification failed #93

Open
spiwocoal opened this issue Aug 30, 2021 · 7 comments
Open

Unable to login, CSRF verification failed #93

spiwocoal opened this issue Aug 30, 2021 · 7 comments

Comments

@spiwocoal
Copy link

I can't seem to send code to Leetcode from Emacs, every time I try using leetcode-try, I get an error with status code 499, and a HTML doc saying the CSRF verification failed, and that I need to enable cookies on my browser. The part with the status code is:

HTTP/1.1 499 Unknown Status Code
Date: Mon, 30 Aug 2021 22:33:24 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
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=X9mUHu33hCDvO6OxEPSIhTVgD9DvAMNen4qI%2BtJsSVYhkdkqrc%2Bpw5phA2zGOpkPvV6Cb23Qn%2BYC91hue02uH5492o2TmlIQW%2FAtlMdjjo7GEv3tvIisJbnfnPqAQg%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: 68717b07cf3885aa-SCL

Weird thing is, I checked my_cookies was working properly and that Emacs had access to the appropriate cookies (and that I was logged in to Leetcode), so I have no idea why this could be happening.

  • OS: OpenSuse Tumbleweed
  • Browser: Firefox 89.0.2
  • Emacs 27.2 with Doom v3.0.0-alpha
@catern
Copy link

catern commented Sep 28, 2021

I'm having the same issue, 499 status code, CSRF verification failed. Perhaps Leetcode changed something?

@kaiwk
Copy link
Owner

kaiwk commented Oct 5, 2021

I tested it with Doom Emacs on mac, using Chrome, and it works fine...

@spiwocoal
Copy link
Author

i am using Firefox, maybe that's why...

once i get home i will try using chromium, if that doesn't work either i'll try using another distro

@YorkZ
Copy link

YorkZ commented Jun 13, 2022

I'm having this problem as well. I use Arch Linux, and have logged in to leetcode web interface in both Firefox and Chromium.

@ileixe
Copy link

ileixe commented Dec 18, 2023

Same here. I can see leetcode session from my_cookies command but 499 returned.

@KAction
Copy link

KAction commented Feb 26, 2024

I have the same, and I believe that token that leetcode.el extracts from the browser gets invalidated once you visit leetcode.el again with browser.

@Xeite
Copy link

Xeite commented Sep 14, 2024

I've debugged this issue today, and finally found (url-cookie-retrieve leetcode--domain "/" t) was returning nil for csrftoken.

That was weird because url-cookie-secure-storage is indeed having csrftoken and the library somehow filtered out the entity. I found this is because my expiration date have different language (Korean in my case) and if the library cannot understand it, it just filtered out.

So I changed locale via sudo localectl set-locale "LC_TIME=en_US.UTF-8" and it started to work now.

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

No branches or pull requests

7 participants