j178 / leetgo

Best LeetCode friend for geek. :snowboarder:
MIT License
539 stars 32 forks source link

[Bug] cannot authenticate with leetcode cookie #256

Closed pansophism closed 10 months ago

pansophism commented 11 months ago

leetgo debug

Full configuration :

author: my_user_name
language: en
code:
  lang: java
  filename_template: '{{ .Id }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  separate_description_file: true
  modifiers:
    - name: removeUselessComments
  go:
    out_dir: go
    modifiers:
      - name: removeUselessComments
      - name: changeReceiverName
      - name: addNamedReturn
      - name: addMod
  python3:
    out_dir: python
    executable: python3
  cpp:
    out_dir: cpp
    cxx: g++
    cxxflags: -O2 -std=c++17
  rust:
    out_dir: rust
  java:
    out_dir: java
leetcode:
  site: https://leetcode.com
  credentials:
    from: browser
    browsers: []
contest:
  out_dir: contest
  filename_template: '{{ .ContestShortSlug }}/{{ .Id }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  open_in_browser: true
editor:
  use: custom
  command: nvim
  args: -o {{.CodeFile}} {{.DescriptionFile}}

### Debug log

```shell
2023/12/27 20:29:34 DEBU cache loaded path=/Users/my_user_name/.config/leetgo/cache/leetcode-questions.json elapsed=183.083µs
2023/12/27 20:29:34 DEBU reading cookies browser=firefox file="/Users/my_user_name/Library/Application Support/Firefox/Profiles/cmg85er1.default/cookies.sqlite"
2023/12/27 20:29:34 DEBU failed to read cookies error="open /Users/my_user_name/Library/Application Support/Firefox/Profiles/cmg85er1.default/cookies.sqlite: no such file or directory"
2023/12/27 20:29:34 DEBU reading cookies browser=firefox file="/Users/my_user_name/Library/Application Support/Firefox/Profiles/dloc8bdq.default-release-1702939840264/cookies.sqlite"
2023/12/27 20:29:34 INFO read LeetCode cookies browser=firefox domain=leetcode.com
2023/12/27 20:29:34 DEBU finished reading cookies elapsed=4.550875ms
2023/12/27 20:29:34 DEBU request method=POST url=https://leetcode.com/graphql
  body=
  │ {"operationName":"questionData","query":"\n\tquery questionData($titleSlug: String!) {\n\t\tquestion(titleSlug: $titleSlug) {\n\t\t\tquestionId\n\t\t\tquestionFrontendId\n\t\t\tcategoryTitle\n\t\t\ttitle\n\t\t\ttitleSlug\n\t\t\tcontent\n\t\t\tisPaidOnly\n\t\t\ttranslatedTitle\n\t\t\ttranslatedContent\n\t\t\tdifficulty\n\t\t\tstatus\n\t\t\tstats\n\t\t\thints\n\t\t\tsimilarQuestions\n\t\t\tsampleTestCase\n\t\t\texampleTestcases\n\t\t\texampleTestcaseList\n\t\t\tmetaData\n\t\t\tcodeSnippets {\n\t\t\t\tlang\n\t\t\t\tlangSlug\n\t\t\t\tcode\n\t\t\t}\n\t\t\ttopicTags {\n\t\t\t\tname\n\t\t\t\tslug\n\t\t\t\ttranslatedName\n\t\t\t}\n\t\t}\n\t}","variables":{"titleSlug":"1166"}}

2023/12/27 20:29:35 FATA invalid qid: user not signed in, your cookies may have expired

Description

cannot seem to authenticate via leetcode cookie even though i have tried to log into leetcode multiple times in the browser

rgbygv commented 11 months ago

Encountered the same issue on leetcode.com, but leetcode.cn is working normally. Here is my dubug info:

lc pick today   
2023/12/28 13:57:26 DEBU request method=POST url=https://leetcode.com/graphql
  body=
  │ {"operationName":"","query":"\n\tquery questionOfToday {\n\t\tactiveDailyCodingChallengeQuestion {\n\t\t\tquestion {\n\t\t\t\ttitleSlug\n\t\t\t}\n\t\t}\n\t}","variables":{}}

2023/12/28 13:57:27 FATA invalid qid: user not signed in, your cookies may have expired
PS D:\leetcode> 
j178 commented 11 months ago

leetcode.com appears to have activated CloudFlare's anti-DDoS protection, resulting in stricter API access. I encountered the same error as you did initially, but after several attempts, it suddenly started working for me. I'm not sure why, but you might want to wait a bit and try again later.

pansophism commented 10 months ago

worked after waiting for couple hours