skygragon / leetcode-cli

A cli tool to enjoy leetcode!
MIT License
3.65k stars 458 forks source link

Could not login with both 'leetcode user -l' and 'leetcode user -c' #218

Open tonardo2015 opened 4 years ago

tonardo2015 commented 4 years ago

I've tried the suggestion to re-login again, it failed again.

  1. login again:

    [root@localhost leetcode-cli]# leetcode user -l
    login: myAccount
    pass:
    [ERROR] invalid password?
  2. run the latest code:

    cd <your local repo>
    git pull --rebase origin master
    ./bin/install   // install globally, OR
    ./bin/leetcode <command>    // run the command locally

    -->

Problem Summary

Could not successfully login leetcode with both leetcode user -l and leetcode user -c

How to reproduce

  1. I tried both leetcode user -l and leetcode user -c both do not work
  2. It is expected to login successfully, but I got [ERROR] invalid password? for leetcode user -l and [ERROR] You are not login yet? for leetcode user -c
  3. The output with "-vv" as below:
    [root@localhost leetcode-cli]# leetcode user -l -vv
    [TRACE] initializing all plugins
    [TRACE] found plugin: cache=default
    [TRACE] found plugin: leetcode=default
    [TRACE] found plugin: retry=default
    [TRACE] inited plugin: leetcode
    [TRACE] inited plugin: retry
    [TRACE] inited plugin: cache
    login: myAccount
    pass:
    [DEBUG] running leetcode.login
    [DEBUG] running leetcode.signin
    ⠋ Signing in leetcode.com[TRACE] REQUEST %s { uri: 'https://leetcode.com/accounts/login/',
    callback: [Function] }
    [TRACE] REQUEST %s make request https://leetcode.com/accounts/login/
    ⠋ Signing in leetcode.com[TRACE] REQUEST %s onRequestResponse https://leetcode.com/accounts/login/ 200 { date: 'Tue, 29 Sep 2020 23:41:49 GMT',
    'content-type': 'text/html; charset=utf-8',
    'transfer-encoding': 'chunked',
    connection: 'close',
    'set-cookie':
    [ '__cfduid=xxxx' ],
    vary: 'Accept-Encoding, Cookie',
    'x-frame-options': 'SAMEORIGIN',
    'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
    'cf-cache-status': 'DYNAMIC',
    'cf-request-id': '057dd778840000ebc97eba9200000001',
    '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?lkg-colo=12&lkg-time=1601422910"}],"group":"cf-nel","max_age":604800}',
    nel: '{"report_to":"cf-nel","max_age":604800}',
    'x-content-type-options': 'nosniff',
    server: 'cloudflare',
    'cf-ray': '5da98ea0df9bebc9-LAX' }
    [TRACE] REQUEST %s reading response's body
    [TRACE] REQUEST %s finish init function https://leetcode.com/accounts/login/
    [TRACE] REQUEST %s response end https://leetcode.com/accounts/login/ 200 { date: 'Tue, 29 Sep 2020 23:41:49 GMT',
    'content-type': 'text/html; charset=utf-8',
    'transfer-encoding': 'chunked',
    connection: 'close',
    'set-cookie':
    [ '__cfduid=xxxx' ],
    vary: 'Accept-Encoding, Cookie',
    'x-frame-options': 'SAMEORIGIN',
    'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
    'cf-cache-status': 'DYNAMIC',
    'cf-request-id': '057dd778840000ebc97eba9200000001',
    '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?lkg-colo=12&lkg-time=1601422910"}],"group":"cf-nel","max_age":604800}',
    nel: '{"report_to":"cf-nel","max_age":604800}',
    'x-content-type-options': 'nosniff',
    server: 'cloudflare',
    'cf-ray': '5da98ea0df9bebc9-LAX' }
    [TRACE] REQUEST %s end event https://leetcode.com/accounts/login/
    [TRACE] REQUEST %s has body https://leetcode.com/accounts/login/ 39167
    [TRACE] REQUEST %s emitting complete https://leetcode.com/accounts/login/
    [TRACE] REQUEST %s { url: 'https://leetcode.com/accounts/login/',
    headers:
    { Origin: 'https://leetcode.com',
     Referer: 'https://leetcode.com/accounts/login/',
     Cookie:
      <hidden> },
    form:
    { csrfmiddlewaretoken:
      'zlPhIZk9zVL7eWY071cmKycEcajyaOkSVSXRSsZxsiSUlkSu38C96caa4uJhR3yd',
     login: 'myAccount',
     password: 'xxxx' },
    callback: [Function],
    method: 'POST' }
    [TRACE] REQUEST %s make request https://leetcode.com/accounts/login/
    [TRACE] REQUEST %s onRequestResponse https://leetcode.com/accounts/login/ 403 { date: 'Tue, 29 Sep 2020 23:41:50 GMT',
    'content-type': 'application/json',
    'content-length': '105',
    connection: 'close',
    'set-cookie':
    [ '__cfduid=xxxx' ],
    vary: 'Cookie',
    'x-frame-options': 'SAMEORIGIN',
    'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
    'cf-cache-status': 'DYNAMIC',
    'cf-request-id': '057dd77ae20000eef6ffa2d200000001',
    '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?lkg-colo=12&lkg-time=1601422910"}],"group":"cf-nel","max_age":604800}',
    nel: '{"report_to":"cf-nel","max_age":604800}',
    'x-content-type-options': 'nosniff',
    server: 'cloudflare',
    'cf-ray': '5da98ea49808eef6-LAX' }
    [TRACE] REQUEST %s reading response's body
    [TRACE] REQUEST %s finish init function https://leetcode.com/accounts/login/
    [TRACE] REQUEST %s response end https://leetcode.com/accounts/login/ 403 { date: 'Tue, 29 Sep 2020 23:41:50 GMT',
    'content-type': 'application/json',
    'content-length': '105',
    connection: 'close',
    'set-cookie':
    [ '__cfduid=xxxx' ],
    vary: 'Cookie',
    'x-frame-options': 'SAMEORIGIN',
    'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
    'cf-cache-status': 'DYNAMIC',
    'cf-request-id': '057dd77ae20000eef6ffa2d200000001',
    '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?lkg-colo=12&lkg-time=1601422910"}],"group":"cf-nel","max_age":604800}',
    nel: '{"report_to":"cf-nel","max_age":604800}',
    'x-content-type-options': 'nosniff',
    server: 'cloudflare',
    'cf-ray': '5da98ea49808eef6-LAX' }
    [TRACE] REQUEST %s end event https://leetcode.com/accounts/login/
    [TRACE] REQUEST %s has body https://leetcode.com/accounts/login/ 105
    [TRACE] REQUEST %s emitting complete https://leetcode.com/accounts/login/
    [ERROR] invalid password?

    The output of leetcode user -c

    [root@localhost leetcode-cli]# leetcode user -c -vv
    [TRACE] initializing all plugins
    [TRACE] found plugin: cache=default
    [TRACE] found plugin: leetcode=default
    [TRACE] found plugin: retry=default
    [TRACE] inited plugin: leetcode
    [TRACE] inited plugin: retry
    [TRACE] inited plugin: cache

    Environment

    • leetcode-cli version: 2.6.2
    • OS version: [root@localhost leetcode-cli]# lsb_release LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch [root@localhost leetcode-cli]# cat /etc/redhat-release CentOS Linux release 7.7.1908 (Core)
[root@localhost leetcode-cli]# leetcode version -v
 _           _                  _
| |         | |                | |
| | ___  ___| |_  ___  ___   __| | ___
| |/ _ \/ _ \ __|/ __|/ _ \ / _` |/ _ \
| |  __/  __/ |_  (__| (_) | (_| |  __/
|_|\___|\___|\__|\___|\___/ \__,_|\___|  CLI v2.6.2

[Environment]
Node                 v10.19.0
OS                   linux 3.10.0-1062.18.1.el7.x86_64
Cache                /root/.lc/leetcode/cache
Config               /root/.lc/config.json

[Configuration]
autologin            {"enable":false,"retry":2}
code                 {"editor":"vim","lang":"cpp"}
file                 {"show":"${fid}.${slug}","submission":"${fid}.${slug}.${sid}.${ac}"}
color                {"enable":true,"theme":"default"}
icon                 {"theme":""}
network              {"concurrency":10,"delay":1}
app                  "leetcode"

[Themes]
Colors               blue,dark,default,molokai,orange,pink,solarized,solarized.light
Icons                ascii,default,win7

[Plugins]
cache                default
retry                default
leetcode             default
sadn1ck commented 4 years ago

Similar result on arch linux, node 12.18.4, npm 6.14.6, installed with nvm

dattadebrup commented 4 years ago

Similar problem in windows.

mjnovice commented 4 years ago

duplicate https://github.com/skygragon/leetcode-cli/issues/194

yaroslavya commented 4 years ago

Is there any update on this one? Same issue, cant login via cli, while browser login works, so the credentials are correct.

1650155187 commented 3 years ago

I have the same problem, anyone has solved it?

MagicFrogSJTU commented 3 years ago

leetcode user -c should work. You should manually copy the total cookie string instead of relying on the automatic process.

For those entrants, I have a Chinese article to illustrate the detail. https://blog.csdn.net/YIforeveralone/article/details/110820913

1650155187 commented 3 years ago

leetcode user -c should work. You should manually copy the total cookie string instead of relying on the automatic process.

For those entrants, I have a Chinese article to illustrate the detail. https://blog.csdn.net/YIforeveralone/article/details/110820913

leetcode submmition command can not use, i want to see the last submmit, do you know why? thanks a lot

lyctw commented 2 years ago

Same issue, any update? My OS is: linux 5.10.79-1-MANJARO

Come across this warning

login: (node:6951) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)