The Wayback Machine - https://web.archive.org/web/20201102184301/https://github.com/LeetCode-OpenSource/vscode-leetcode/issues/478
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

Failed to log in with a leetcode.com account #478

Open
queensferryme opened this issue Nov 23, 2019 · 130 comments
Open

Failed to log in with a leetcode.com account #478

queensferryme opened this issue Nov 23, 2019 · 130 comments
Labels

Comments

@queensferryme
Copy link

@queensferryme queensferryme commented Nov 23, 2019

🐛 Bug Report

I can't log into my leetcode.com account via vscode plugin, but I can log in with the same email & password in the browser.
In contrast, my leetcode-cn.com account seems to work fine with this vscode plugin.

To Reproduce

None

Expected behavior

Log into my leetcode.com account.

Extension Output

login:  Active  Name               Version         Desc
----------------------------------------------------------------------------------------------------
   ✔     solution.discuss   2019.02.03      Plugin to fetch most voted solution in discussions.
   ✔     company            2017.12.18      Plugin to query by company for free user.
   ✔     cache              default         Plugin to provide local cache.
   ✔     retry              default         Plugin to retry last failed request if autologin.enable is on.
   ✘     leetcode.cn        2018.11.25      Plugin to talk with leetcode-cn APIs.
   ✔     leetcode           default         Plugin to talk with leetcode APIs.
[ERROR] You are not login yet?
login: pass: - Signing in leetcode.com
[ERROR] invalid password?

Your Environment

  • os: Windows 10 Family Edition x64 (#18362)
  • extension settings: default
  • nodejs version: 12.4.0
  • vscode version: 1.40.1
  • extension version: 0.15.7
@queensferryme
Copy link
Author

@queensferryme queensferryme commented Nov 23, 2019

I am afraid this is an issue with the upstream project leetcode-cli.

image

@eeliu
Copy link

@eeliu eeliu commented Nov 23, 2019

+1

@eeliu
Copy link

@eeliu eeliu commented Nov 23, 2019

How to make it works?
Anyone, please help us.

@ylaurent
Copy link

@ylaurent ylaurent commented Nov 23, 2019

+1

1 similar comment
@mpirbhoy
Copy link

@mpirbhoy mpirbhoy commented Nov 23, 2019

+1

@zhoujf620
Copy link

@zhoujf620 zhoujf620 commented Nov 24, 2019

I have the same problem that I switched to leetcode-cn endpoint yesterday but cannot login my leetcode account anymore. I have tried to use the mobile's hotpot and vpn global mode, still failed.

Is there any solution to solve this problem?

P.S. reinstalling cannot solve this.

Extension Output

login: login: Active Name Version Desc

✘ solution.discuss 2019.02.03 Plugin to fetch most voted solution in discussions.
✘ company 2017.12.18 Plugin to query by company for free user.
cache default Plugin to provide local cache.
retry default Plugin to retry last failed request if autologin.enable is on.
✘ leetcode.cn 2018.11.25 Plugin to talk with leetcode-cn APIs.
leetcode default Plugin to talk with leetcode APIs.
/Users/albert/.vscode/extensions/shengchen.vscode-leetcode-0.15.7/node_modules/yargs/yargs.js:1148
else throw err
^

TypeError: Cannot read property 'toString' of undefined
at /Users/albert/.vscode/extensions/shengchen.vscode-leetcode-0.15.7/node_modules/vsc-leetcode-cli/lib/log.js:55:31
at Array.map ()
at Object.log. [as info] (/Users/albert/.vscode/extensions/shengchen.vscode-leetcode-0.15.7/node_modules/vsc-leetcode-cli/lib/log.js:55:20)
at Object.cmd.handler (/Users/albert/.vscode/extensions/shengchen.vscode-leetcode-0.15.7/node_modules/vsc-leetcode-cli/lib/commands/user.js:59:11)
at Object.runCommand (/Users/albert/.vscode/extensions/shengchen.vscode-leetcode-0.15.7/node_modules/yargs/lib/command.js:238:44)
at Object.parseArgs [as _parseArgs] (/Users/albert/.vscode/extensions/shengchen.vscode-leetcode-0.15.7/node_modules/yargs/yargs.js:1063:30)
at Object.get [as argv] (/Users/albert/.vscode/extensions/shengchen.vscode-leetcode-0.15.7/node_modules/yargs/yargs.js:1004:21)
at runCommand (/Users/albert/.vscode/extensions/shengchen.vscode-leetcode-0.15.7/node_modules/vsc-leetcode-cli/lib/cli.js:86:5)
at /Users/albert/.vscode/extensions/shengchen.vscode-leetcode-0.15.7/node_modules/vsc-leetcode-cli/lib/cli.js:103:5
at initPlugins (/Users/albert/.vscode/extensions/shengchen.vscode-leetcode-0.15.7/node_modules/vsc-leetcode-cli/lib/cli.js:64:12)
login: pass: - Signing in leetcode.com
[ERROR] invalid password?

@twang9
Copy link

@twang9 twang9 commented Nov 24, 2019

same issue

@BaccanoEva
Copy link

@BaccanoEva BaccanoEva commented Nov 25, 2019

+1

@jdneo jdneo added the help wanted label Nov 25, 2019
@qiwei9743
Copy link

@qiwei9743 qiwei9743 commented Nov 25, 2019

+1

1 similar comment
@Kalyan-M
Copy link

@Kalyan-M Kalyan-M commented Nov 25, 2019

+1

@yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented Nov 25, 2019

Seems the same prblems.
I try to locate it, one may cause the problem is that the leetcode.com use the recaptcha_token for now. And the code in leetcode-cli doesn't have it.
222

But the leetcode-cn's payload is as usual.
image

And the leetcode-cli's login payload is like below.
image

I think may use another way to login and get the session or solve the recaptcha.

@jdneo @queensferryme

@RushviShah
Copy link

@RushviShah RushviShah commented Nov 25, 2019

+1

@Vigoose
Copy link

@Vigoose Vigoose commented Nov 25, 2019

same issue

@LincolnZeng
Copy link

@LincolnZeng LincolnZeng commented Nov 26, 2019

same bug here, can not login while same username and pw are working fine on leetcode website

@joey66666
Copy link

@joey66666 joey66666 commented Nov 26, 2019

+1, the same issue.

@oasis10702
Copy link

@oasis10702 oasis10702 commented Nov 26, 2019

+1, same issue

@Holybasil
Copy link

@Holybasil Holybasil commented Nov 27, 2019

same

@jdneo
Copy link
Member

@jdneo jdneo commented Nov 27, 2019

Hi @ALL,

Sorry I'm busying with my work these days. Hope we could have volunteers who are interested to provide fixed in the upstream repo: https://github.com/leetcode-tools/leetcode-cli

@yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented Nov 27, 2019

Hi @jdneo

I try to fix the problems in leetcode-cli

But leetcode.com use recaptcha which is hard to generate the token when use post to login.
Also I try to use puppeteer to login and get session but the recaptcha also exists.

Now I think two ways maybe can avoid it for now , Because the recaptcha only used in login api, others were not affected.

  1. open the session method to help user to store(which can get in chrome ) in vscode leetcode session
  2. use third-party to login (such as github) and get the session
    But these ways are not simple and elegant.

I am still trying other ways
And for now, the leetcode-cn doesn't add the recaptcha, everyone can try it (dump data from leetcode to leetcode-cn) and select leetcode-cn in vscode-leetcode
Hope someone have a better way to fix it.

Thank you

@jdneo
Copy link
Member

@jdneo jdneo commented Nov 27, 2019

@yihong0618 Thank you for the great effort! I guess if leetcode has applied the recaptcha token. leetcode-cn will finally migrate to it in some time. Hope we can find a way to resolve it.

Thank you again!

@glucas350
Copy link

@glucas350 glucas350 commented Nov 27, 2019

+1

@CoolersCoder
Copy link

@CoolersCoder CoolersCoder commented Nov 27, 2019

@jdneo 登录页https://leetcode.com/accounts/login/ 首次登陆会生成一个 id名为recaptcha-token,这个就是@yihong0618 说的谷歌的https://www.google.com/recaptcha/intro/v3.html

每次用户登陆的时候貌似都要检查一下这个hidden的value. 有没有办法存储在plugin临时文件里? 因为没有开发过plugin不清楚是否可行。

<input id="recaptcha-token" type="hidden" value="03AOLTBLRLMf9Mib_S4ixPeHd9qQQjEpPRvs1NVhsWvJogjBEZriWO-0L58e5Umzd3b5l98t2vW2s532-jSRqQRr23lZuJSx_PyClRRIjK4Wjv6pUh5pafJRvLLYTZqMbJ3JtiwlohtKDiggB6yYqsFZNY_t8IDnHlWKivV4SvW6nCSGjg4aFGTfySip7QlUQv5N54E_V4BmmffNoLrEr2tMgiODzSCy7TbA9rUHO4RbI30HQsF4sZt9pGk3u2RbUaeNxDWqyxeTuvPOrz8LgNoOeST142GkHHoCiVwbFcm1lPDBLizIbKpf77YwNdg0FhtqJq1SJcq35PniBEdEMH8EMB_kH2KJcTK51_X_cqUH2ddOzMxwoMPn95lQn5m7w3UjKPUxI-zAKDRtEook66jJK3TNwT7QdTK3edZjNs1znypTgA0Et3kO8">
const opts = {
      url: config.sys.urls.login,
      headers: {
        Origin: config.sys.urls.base,
        Referer: config.sys.urls.login,
        Cookie: 'csrftoken=' + user.loginCSRF + ';'
      },
      form: {
        csrfmiddlewaretoken: user.loginCSRF,
        login: user.login,
        password: user.pass
       //probably here, we might need one more recaptcha-token
      }
};
@yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented Nov 27, 2019

@CoolersCoder
Thank you very much for your help.
This value is generate by google-recaptcha, and will also check if you are a robot, so use puppeteer will call a robot check, so this value can't store.
And I still not find an easy to slove this, sad.

@lostindark
Copy link

@lostindark lostindark commented Nov 28, 2019

This problem is a little bit tricky. Recaptcha is hard to deal without a browser. I can think of 2 ways to fix this:

  1. Host the login page in an embedded browser, and extract session token when login finishes. puppeteer?
  2. If leetcode supports OAuth2 (I don't know as I can't find any document of leetcode API), the plugin can host a client app and use browser to login. Once login finishes and the plugin can get the token for leetcode API.

None of these are simple, maybe we should talk to leetcode and see if there are any support way of login for plugins?

@jdneo
Copy link
Member

@jdneo jdneo commented Nov 28, 2019

@lostindark Thank you, I'll try to reach leetcode recently. But I'm not sure who should be talked to. If anyone knows, please let me know.

@yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented Nov 28, 2019

@jdneo @lostindark

  1. I had tried to use puppeteer but using puppeteer will cause a rotbot check problem.
  2. And the sencond way I also do my best to try but faild, and I happend to find that leetcode is beta their app, maybe we can try to get some luck

@jdneo

  1. I have try to session login that user can copy the cookie from chrome(or others) then paste to the vscode input field, one time login then all the others features are not affected so the user can use vscode-leetcode as usual, can I compelete it and pull request for short-term solution ?

The demo will be like below (user can only copy the cookie and vscode-cli will parser it ):
image

image

This cookie but need to add some guide。
image

@lostindark
Copy link

@lostindark lostindark commented Nov 28, 2019

@yihong0618 Have you tried to turn headless off?

const browser = await puppeteer.launch({
  headless: false
})

The other way to try is to set a normal chrome user agent and see if that works.
await page.setUserAgent(<valid chrome user agent>)

@yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented Feb 18, 2020

@yihong0618 Interesting I have not seen such a entry box. I have just tried again, and it shows a popup in the right bottom corner saying that it failed and check the console.

Maybe it is because I have a hardware security key as a 2fa method?

I think so.

@finalxcode
Copy link

@finalxcode finalxcode commented Feb 21, 2020

Any step-by-step instructions to solve the problem temporily ? thanks!

Spent an hour and figured it out. Here are the step by step instructions by people newbie like me.

  1. Make sure Node.js 8+ is installed. Instructions can be found on the official page
  2. Install leetcode-cli from OS terminal or the terminal within vscode. Installation guide. Note the "From Github" section links to an older version.
# to remove the old version
npm uninstall -g leetcode-cli
# to install the up-to-date version(2.6.17+)
npm install -g leetcode-tools/leetcode-cli

Type leetcode version in terminal to make sure you installed version 2.6.17+.

  1. Log into leetcode.com in a browser. In Chrome, right click and select "Inspect". Switch to tab "Network", "XHR". Then click any button on leetcode.com(now should be on the left split screen). Now you should be able to see the cookie as @yihong0618 showed in the pic. Copy the entire cookie string starting from "__cfduid" and ending with "_gat=1"
  2. Type leetcode user -c from terminal within vscode. Follow the prompt and type in your username and cookie you copied above.

Hmm, even though I was successfully able to sign in via cookie login none of the problems are being displayed and when I try to sign in again it says "invalid password". What exactly am I suppose to do when I'm logged in using the cookie method?
And also, Command Shift P isn't working for me.

It works for me on MacOS . Thanks!!!!!

Thanks !!!

@dustfreer
Copy link

@dustfreer dustfreer commented Mar 25, 2020

Any step-by-step instructions to solve the problem temporily ? thanks!

Spent an hour and figured it out. Here are the step by step instructions by people newbie like me.

  1. Make sure Node.js 8+ is installed. Instructions can be found on the official page
  2. Install leetcode-cli from OS terminal or the terminal within vscode. Installation guide. Note the "From Github" section links to an older version.
# to remove the old version
npm uninstall -g leetcode-cli
# to install the up-to-date version(2.6.17+)
npm install -g leetcode-tools/leetcode-cli

Type leetcode version in terminal to make sure you installed version 2.6.17+.

  1. Log into leetcode.com in a browser. In Chrome, right click and select "Inspect". Switch to tab "Network", "XHR". Then click any button on leetcode.com(now should be on the left split screen). Now you should be able to see the cookie as @yihong0618 showed in the pic. Copy the entire cookie string starting from "__cfduid" and ending with "_gat=1"
  2. Type leetcode user -c from terminal within vscode. Follow the prompt and type in your username and cookie you copied above.

Hmm, even though I was successfully able to sign in via cookie login none of the problems are being displayed and when I try to sign in again it says "invalid password". What exactly am I suppose to do when I'm logged in using the cookie method?
And also, Command Shift P isn't working for me.

It works for me on MacOS . Thanks!!!!!

Thanks !!!

works for my MacOS ,thanks

@wds3817
Copy link

@wds3817 wds3817 commented Apr 4, 2020

cmccvic Thx

@pawan07thapa
Copy link

@pawan07thapa pawan07thapa commented Apr 4, 2020

@jdneo @lostindark

  1. I had tried to use puppeteer but using puppeteer will cause a rotbot check problem.
  2. And the sencond way I also do my best to try but faild, and I happend to find that leetcode is beta their app, maybe we can try to get some luck

@jdneo

  1. I have try to session login that user can copy the cookie from chrome(or others) then paste to the vscode input field, one time login then all the others features are not affected so the user can use vscode-leetcode as usual, can I compelete it and pull request for short-term solution ?

The demo will be like below (user can only copy the cookie and vscode-cli will parser it ):
image

image

This cookie but need to add some guide。
image

Thanks a bunch! this worked for me!

@chenyunli6
Copy link

@chenyunli6 chenyunli6 commented May 3, 2020

I use Github account and login successfully.

@hoyangtsai
Copy link

@hoyangtsai hoyangtsai commented May 3, 2020

Why not just updating the latest version of leetcode-cli in the extension, instead of installing another npm package globally.

@xubeng
Copy link

@xubeng xubeng commented May 6, 2020

I use Github account and login successfully.

I can't in the latest version by Macbook.

@yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented May 7, 2020

I use Github account and login successfully.

I can't in the latest version by Macbook.

Is there any log?

@sanketvega
Copy link

@sanketvega sanketvega commented May 16, 2020

Still facing this error.
With cookies it fails with TypeError: Cannot read property 'isCurrentUserPremium' of null
Doesnt login with github because of TFA and linkedin too.

@code-talking
Copy link

@code-talking code-talking commented May 17, 2020

I encounter the same issue initially. However, I found that we could use plugin to solve it. Steps are below:

  1. login your leetcode in browser(chrome).
  2. install plugin, cookie.chrome. Now, the terminal could share the cookies in browser
  3. leetcode user -l, use your correct username and password to login. It should succeed ideally.
@ggufeng
Copy link

@ggufeng ggufeng commented Sep 4, 2020

I encounter the same issue initially. However, I found that we could use plugin to solve it. Steps are below:

  1. login your leetcode in browser(chrome).
  2. install plugin, cookie.chrome. Now, the terminal could share the cookies in browser
  3. leetcode user -l, use your correct username and password to login. It should succeed ideally.

what you mean for cookie.chrome, I cannot find such a plugin.

@BismeetSingh
Copy link

@BismeetSingh BismeetSingh commented Sep 8, 2020

This extension simply doesn't work.

@yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented Sep 8, 2020

@BismeetSingh
Can you try to link your LeetCode account to LinkedIn or GitHub account, then login, I tried these way and succeed.

@BismeetSingh
Copy link

@BismeetSingh BismeetSingh commented Sep 8, 2020

@yihong0618
Can you try to link your LeetCode account to LinkedIn or GitHub account, then login, I tried these way and succeed.

Does it work with gmail?I cant afford to lose my progress via a new account.

@yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented Sep 8, 2020

@yihong0618
Can you try to link your LeetCode account to LinkedIn or GitHub account, then login, I tried these way and succeed.

Does it work with gmail?I cant afford to lose my progress via a new account.

Not, or you can copy the cookie with login with cookie, the setups you can find in this issue.

@BismeetSingh
Copy link

@BismeetSingh BismeetSingh commented Sep 8, 2020

@yihong0618
That is exactly the thing which isnt working.

@BismeetSingh
Copy link

@BismeetSingh BismeetSingh commented Sep 8, 2020

image
Do I have to copy this content, as shown in the image?

@yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented Sep 8, 2020

  1. you must login on the chrome or something else.
  2. click one link that you can find the cookie in xhr I clicked the all problems
  3. copy the cookie(the whole content) which is mine below

image

@BismeetSingh
Copy link

@BismeetSingh BismeetSingh commented Sep 8, 2020

@yihong0618
Thanks, it works now.

@yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented Sep 8, 2020

@yihong0618
Thanks, it works now.

My pleasure.

@jdneo
Copy link
Member

@jdneo jdneo commented Sep 8, 2020

@yihong0618 Maybe we need to add the login related steps into the readme page? what do you think?

@yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented Sep 8, 2020

@yihong0618 Maybe we need to add the login related steps into the readme page? what do you think?

@jdneo maybe just a link to vscode-leetcode wiki like you did before, because there may have some setups and leetcode and leetcode are different that made readme bigger.

@jdneo
Copy link
Member

@jdneo jdneo commented Sep 8, 2020

Sure, would you mind to add them in the wiki?

@yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented Sep 8, 2020

Sure, would you mind to add them in the wiki?

Of course, maybe I can try this this weekend~

@jdneo
Copy link
Member

@jdneo jdneo commented Sep 8, 2020

@yihong0618 Thank you, as always 👍

@plonkchao
Copy link

@plonkchao plonkchao commented Sep 21, 2020

@yihong0618 @jdneo
When i type leetcode user -c in the MacOS terminal, it appeared [ERROR] You are not login yet?.
How can i fix it?please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.