Closed g-kartik closed 8 months ago
I think it is duplicate of #256.
I also have problem to use leetgo on leetcode.com
.
I am able to pick problems with leetcode.cn
.
I tried both via cookies
and browser
(which worked well before). Since 06.03.2024 all my tries end up with same:
invalid qid: user not signed in, your cookies may have expired
When I try to
leetgo pick today
# output:
invalid qid: user not signed in, your cookies may have expired
but when I try to use:
leetgo pick name-of-task
# output:
× failed to load cache, try updating with `leetgo cache update` err="stat /home/name/.config/leetgo/cache/leetcode-questions.json: no such file or directory"
● read LeetCode cookies browser=firefox domain=leetcode.com
× invalid qid: user not signed in, your cookies may have expired
# or if I have no variables setup for cookies or I am not login on leetcode
× failed to load cache, try updating with `leetgo cache update` err="stat /home/name/.config/leetgo/cache/leetcode-questions.json: no such file or directory"
● add credentials failed, continue requesting without credentials err="cookies not found"
× invalid qid: user not signed in, your cookies may have expired
So I think we can assume that it reads cookies properly.
I tried with v1.3.13
and v1.4.1
.
Any idea on how can we make it work on Leetcode us site? I don't understand Chinese.
I have the same issue. I try to use graphql with insomnia, it still was blocked by cloudflare. Still don't know how to bypass this one.
Hi, @th0j @g-kartik @Cvaniak I just pushed a commit attempting to resolve this. Please see if it works for you:
go run github.com/j178/leetgo@master whoami
If you're providing cookies manually, grab a cf_clearance
cookie and set it to LEETCODE_CFCLEARANCE
env var. Let me know how it goes!
The issue might related to this discussion in Reddit. It seems that Leetcode did restrict basic crawler 4 days ago. It should be the same date @Cvaniak got their issue.
Here is the curl script that works sometime:
curl \
--location "https://leetcode.com/graphql/" \
--header "Content-Type: application/json" \
--header "User-Agent: ME" \
--header "Cookie: LEETCODE_SESSION=<LEETCODE_SESSION>; csrftoken=<csrftoken>" \
--data '{"query":"query problemsetQuestionList($categorySlug: String, $limit: Int, $skip: Int, $filters: QuestionListFilterInput) {\n problemsetQuestionList: questionList(\n categorySlug: $categorySlug\n limit: $limit\n skip: $skip\n filters: $filters\n ) {\n total: totalNum\n questions: data {\n acRate\n difficulty\n freqBar\n frontendQuestionId: questionFrontendId\n isFavor\n paidOnly: isPaidOnly\n status\n title\n titleSlug\n topicTags {\n name\n id\n slug\n }\n hasSolution\n hasVideoSolution\n }\n }\n}","variables":{"categorySlug":"","skip":0,"limit":1,"filters":{}}}' \
It works with my environment occasionally while mostly it will return something like "just a moment".
I noticed that Leetgo already add User-Agent in all request except authentication. However, it doesn't work even once under the same env with either browser or cookies option. There might be some filtering behind while I am not sure what that is.
I figure out that turning off http2 seems to do the trick; now leetcode.com is consistently working for me. Could someone else confirm it by running?
go run github.com/j178/leetgo@master whoami
Can pick problem, but can't submit.
go run github.com/j178/leetgo@master whoami
× [403 Forbidden] user not signed in, your cookies may have expired
exit status 1
lc test last -Ls --lang rust --site us
● running test locally question=custom-sort-string
● building file=rust/src/0791.custom-sort-string/solution.rs
● Case 1: Skipped: no output
● submitting solution user=aaaaaa@leetcode.com
× failed to submit solution err="failed to submit solution: user not signed in, your cookies may have expired"
I figure out that turning off http2 seems to do the trick; now leetcode.com is consistently working for me. Could someone else confirm it by running?
go run github.com/j178/leetgo@master whoami
It works for me at this moment.
I figure out that turning off http2 seems to do the trick; now leetcode.com is consistently working for me. Could someone else confirm it by running?
go run github.com/j178/leetgo@master whoami
It also works for me. I hope it will solve this problem for good.
Thank you very much! As always - quick and working solution!
Thank you @j178 for such quick fixes. It have tried setting environment variables as you told. It works absolutely fine.
Hi, @th0j @g-kartik @Cvaniak I just pushed a commit attempting to resolve this. Please see if it works for you:
go run github.com/j178/leetgo@master whoami
If you're providing cookies manually, grab a
cf_clearance
cookie and set it toLEETCODE_CFCLEARANCE
env var. Let me know how it goes!
Hi everyone, I've released v1.4.2 which might mitigate this issue. Interestingly, this morning leetgo
can access leetcode.com successfully even without those changes :) It's werid, so I can not promoise this issue will not come again, but rest assured, I'll be keeping watch on this.
leetgo debug
Leetgo version info :
Home dir : /home/gkrj/.config/leetgo Project root : /mnt/ssd/work Working dir : /mnt/ssd/work Project config file : /mnt/ssd/work/leetgo.yaml Project configuration:
Full configuration :
Debug log
Description
I ran
leetgo pick 1
. I have set the LEETCODE_SESSION and LEETCODE_CSRFTOKEN as environment variables from my logged in Leetcode account and yet I am unable to login.