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

Cannot login with premium account #194

Open
michaelhly opened this issue Nov 23, 2019 · 17 comments
Open

Cannot login with premium account #194

michaelhly opened this issue Nov 23, 2019 · 17 comments

Comments

@michaelhly
Copy link

Problem Summary

Recently bought premium and can't seem to log in anymore.

How to reproduce

Ran ./bin/leetcode user --login -vv
Get: [ERROR] invalid password? (403 forbidden)

Here is the full trace:

[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: mylogin
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: 'Sat, 23 Nov 2019 04:51:13 GMT',
  'content-type': 'text/html; charset=utf-8',
  'transfer-encoding': 'chunked',
  connection: 'close',
  'set-cookie': [...],
  vary: 'Accept-Encoding, Cookie',
  'x-frame-options': 'SAMEORIGIN',
  'cf-cache-status': 'DYNAMIC',
  'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
  'x-content-type-options': 'nosniff',
  'expect-ct':
   'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
  server: 'cloudflare',
  'cf-ray': '...' }
[TRACE] REQUEST %s reading response's body
[TRACE] REQUEST %s finish init function https://leetcode.com/accounts/login/
⠼ Signing in leetcode.com[TRACE] REQUEST %s response end https://leetcode.com/accounts/login/ 200 { date: 'Sat, 23 Nov 2019 04:51:13 GMT',
  'content-type': 'text/html; charset=utf-8',
  'transfer-encoding': 'chunked',
  connection: 'close',
  'set-cookie': [...],
  vary: 'Accept-Encoding, Cookie',
  'x-frame-options': 'SAMEORIGIN',
  'cf-cache-status': 'DYNAMIC',
  'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
  'x-content-type-options': 'nosniff',
  'expect-ct':
   'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
  server: 'cloudflare',
  'cf-ray': '...' }
[TRACE] REQUEST %s end event https://leetcode.com/accounts/login/
[TRACE] REQUEST %s has body https://leetcode.com/accounts/login/ 32265
[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: '...',
     login: 'redacted_login',
     password: 'redacted_password' },
  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: 'Sat, 23 Nov 2019 04:51:14 GMT',
  'content-type': 'text/html; charset=utf-8',
  'transfer-encoding': 'chunked',
  connection: 'close',
  'set-cookie': [ ...],
  vary: 'Cookie',
  'x-frame-options': 'SAMEORIGIN',
  'cf-cache-status': 'DYNAMIC',
  'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
  'x-content-type-options': 'nosniff',
  'expect-ct':
   'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
  server: 'cloudflare',
  'cf-ray': '...' }
[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: 'Sat, 23 Nov 2019 04:51:14 GMT',
  'content-type': 'text/html; charset=utf-8',
  'transfer-encoding': 'chunked',
  connection: 'close',
  'set-cookie': [...],
  vary: 'Cookie',
  'x-frame-options': 'SAMEORIGIN',
  'cf-cache-status': 'DYNAMIC',
  'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
  'x-content-type-options': 'nosniff',
  'expect-ct':
   'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
  server: 'cloudflare',
  'cf-ray': '...' }
[TRACE] REQUEST %s end event https://leetcode.com/accounts/login/
[TRACE] REQUEST %s emitting complete https://leetcode.com/accounts/login/
[ERROR] invalid password?

Environment

  • leetcode-cli version: 2.6.2-5245886
  • OS version: darwin 18.6.0
  • Node version: v10.16.2
  • Npm version: 6.9.0
@yishanhe
Copy link

csrfmiddlewaretoken: xxx
login: xxx
password: xxx
next: /
recaptcha_token: xxx

Not familiar with this, but I check the request/response on leetcode website and saw this recaptcha_token, can anyone educate me what is effect of this token here? Thanks.

@chishui
Copy link

chishui commented Nov 23, 2019

https://developers.google.com/recaptcha/intro

Welcome to the reCAPTCHA developer documentation.

reCAPTCHA protects you against spam and other types of automated abuse. Here, we explain how to add reCAPTCHA to your site or application.

@kgfly
Copy link

kgfly commented Nov 24, 2019

+1, code here https://github.com/leetcode-tools/leetcode-cli does not work either.

@huangyingw
Copy link

most probably, leetcode recently enhance the security set of its API, that's why our login request failed. I am trying to fix this issue, but no luck yet...

@wey-gu
Copy link

wey-gu commented Nov 28, 2019

I am not handly on JS, possibly this captcha-solver may help?
Thanks!

@rgatti
Copy link

rgatti commented Nov 29, 2019

It seems I'm able to get the cli working by manually logging into the site in a browser, viewing the cookies, and creating the ~/.lc/leetcode/user.json by hand. My file looks like ...

{
  "login": "[username]",
  "loginCSRF": "",
  "sessionCSRF": "[copied from csrftoken]",
  "sessionId": "[copied from LEETCODE_SESSION]"
}

Currently, I've only tested showing my account status and listing problems.

@dorianHe
Copy link

dorianHe commented Dec 2, 2019

It seems I'm able to get the cli working by manually logging into the site in a browser, viewing the cookies, and creating the ~/.lc/leetcode/user.json by hand. My file looks like ...

{
  "login": "[username]",
  "loginCSRF": "",
  "sessionCSRF": "[copied from csrftoken]",
  "sessionId": "[copied from LEETCODE_SESSION]"
}

Currently, I've only tested showing my account status and listing problems.

I am trying your tips. But I don't know how can I find my LEETCODE_SESSION. Could you tell me where I can find it?

@rgatti
Copy link

rgatti commented Dec 2, 2019

It seems I'm able to get the cli working by manually logging into the site in a browser, viewing the cookies, and creating the ~/.lc/leetcode/user.json by hand. My file looks like ...

{
  "login": "[username]",
  "loginCSRF": "",
  "sessionCSRF": "[copied from csrftoken]",
  "sessionId": "[copied from LEETCODE_SESSION]"
}

Currently, I've only tested showing my account status and listing problems.

I am trying your tips. But I don't know how can I find my LEETCODE_SESSION. Could you tell me where I can find it?

After logging into LeetCode I'm using the storage inspector to grab the cookie values, https://developer.mozilla.org/en-US/docs/Tools/Storage_Inspector.

@dorianHe
Copy link

dorianHe commented Dec 2, 2019

It seems I'm able to get the cli working by manually logging into the site in a browser, viewing the cookies, and creating the ~/.lc/leetcode/user.json by hand. My file looks like ...

{
  "login": "[username]",
  "loginCSRF": "",
  "sessionCSRF": "[copied from csrftoken]",
  "sessionId": "[copied from LEETCODE_SESSION]"
}

Currently, I've only tested showing my account status and listing problems.

I am trying your tips. But I don't know how can I find my LEETCODE_SESSION. Could you tell me where I can find it?

After logging into LeetCode I'm using the storage inspector to grab the cookie values, https://developer.mozilla.org/en-US/docs/Tools/Storage_Inspector.

Thank you very much for the quick reply!

@rony36
Copy link

rony36 commented Jul 13, 2020

I sovled this problem by using cookie.chrome plugin.
Seems need to disable some other plugins to make it works.

leetcode plugin -d leetcode.cn
leetcode plugin  -d lintcode
leetcode user -l -v

@mmurshed
Copy link

I faced the same problem. Even after using the token I get locked question error with my premium account.

@luxp
Copy link

luxp commented Aug 2, 2020

You can try this workshop based on leetcode-cli for workaround: https://github.com/luxp/leetcode-workshop-javascript

Instead of submit with cli, it will automatically copy the submit content to the clipboard and open the problem page. You just need to paste it.

And by the way, you can use jest to test your code locally, which is really helpful and fast for debug and verification.

@orifmilod
Copy link

orifmilod commented Nov 16, 2020

For those who want to find data below, just go to chrome and paste this
chrome://settings/cookies/detail?site=leetcode.com

{
  "login": "[username]",
  "loginCSRF": "",
  "sessionCSRF": "[copied from csrftoken]",
  "sessionId": "[copied from LEETCODE_SESSION]"
}

Edit:

It seems like the link above no longer works: Go to leetcode.com and open inspect tab
Paste this in the console and press enter: Object.fromEntries(document.cookie.split('; ').map(v=>v.split(/=(.*)/s).map(decodeURIComponent)))

Then you should see it return your cookies. You can then copy sessionCSRF from csrftoken and sessionId from [xxxxxxxx]_gr_session_id

@songyu-wang98
Copy link

For those who want to find data below, just go to chrome and paste this
chrome://settings/cookies/detail?site=leetcode.com

{
  "login": "[username]",
  "loginCSRF": "",
  "sessionCSRF": "[copied from csrftoken]",
  "sessionId": "[copied from LEETCODE_SESSION]"
}

love u bro

@edte edte mentioned this issue Jul 26, 2022
@shalimujiang
Copy link

For those who want to find data below, just go to chrome and paste this对于那些想在下面找到数据的人,只需转到 chrome 并粘贴即可 chrome://settings/cookies/detail?site=leetcode.comchrome://settings/cookies/detail?site=leetcode.com

{
  "login": "[username]",
  "loginCSRF": "",
  "sessionCSRF": "[copied from csrftoken]",
  "sessionId": "[copied from LEETCODE_SESSION]"
}

The plugin was working fine before then I uninstalled and reinstalled vim as well as installed the plugin and couldn't log in later. I tried your method, I don't know what I filled in wrong, can you correct me? Thank you!
image
image
image
Linux localhost 5.10.43 #1 SMP PREEMPT Thu Aug 18 17:40:54 CST 2022 aarch64 Android
(WJXN76O4$}FCX94W%`KWQ6

@orifmilod
Copy link

@shalimujiang I have made an edit in my comment above and I think the values can be obtained using another way. Hope it works :)

@dsshay
Copy link

dsshay commented Mar 2, 2024

@shalimujiang how you launch command "leetcode user -l" using user.json?

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