The Wayback Machine - https://web.archive.org/web/20220304162113/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 · 184 comments
Open

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

queensferryme opened this issue Nov 23, 2019 · 184 comments

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?

@tcwtc
Copy link

@tcwtc tcwtc commented Nov 24, 2019

same issue

@BaccanoEva
Copy link

@BaccanoEva BaccanoEva commented Nov 25, 2019

+1

@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

@zzjoey
Copy link

@zzjoey zzjoey 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>)

@WeslleyYun
Copy link

@WeslleyYun WeslleyYun commented Jun 28, 2021

I have tried this solution and could log in at the moment but got the error instantly:

`- Retrieving user profile
Successfully login as weslley

* Downloading problems
  (node:16992) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
  (Use node --trace-warnings ... to show where the warning was created)
  [ERROR] session expired, please login again [code=-1]`

1、找到leetcode插件位置,打开leetcode.js,找到这个位置
image
2、在网页上登录https://leetcode-cn.com/,登录成功之后F12,
image
copy LEETCODE_SESSION和csrftoken,注意对应
3、修改leetcode.js上面的代码
image
然后保存,之后在vscode登录leetcode, 选择直接登录,账号密码随便输入就行

I don't know why, but after trying several times, I logged in via this method for now.

@sam-brownlow
Copy link

@sam-brownlow sam-brownlow commented Jun 28, 2021

this method is still working

#478 (comment)

@arshappleid
Copy link

@arshappleid arshappleid commented Aug 20, 2021

You should look at how the algorithm extension, which is similar to this tries to log in. That extension can still log in to leetcode , although it does not work.
@chengengliu

@sober-wang
Copy link

@sober-wang sober-wang commented Sep 6, 2021

the login is awful! : (

if you want sync use configuration in the vscode can use github.com account login . So the leetcode plugin need forward the login, beacuse I used github.com to login the leetcode website.

@saksham1211
Copy link

@saksham1211 saksham1211 commented Sep 30, 2021

Hi,
Does any of the solution working for anyone? I tried all of the above suggested solutions, none of them worked for me.
Any help would be appreciated.

Thanks

@saksham1211
Copy link

@saksham1211 saksham1211 commented Sep 30, 2021

Login from Github--third party is causing error

login: (node:23440) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
pass: c:\Users\sdubey\.vscode\extensions\leetcode.vscode-leetcode-0.18.0\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:552
    const redirectUri = resp.request.uri.href;
                             ^

TypeError: Cannot read property 'request' of undefined
    at Request._callback (c:\Users\sdubey\.vscode\extensions\leetcode.vscode-leetcode-0.18.0\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:552:30)
    at self.callback (c:\Users\sdubey\.vscode\extensions\leetcode.vscode-leetcode-0.18.0\node_modules\request\request.js:185:22)
    at Request.emit (events.js:400:28)
    at Request.onRequestError (c:\Users\sdubey\.vscode\extensions\leetcode.vscode-leetcode-0.18.0\node_modules\request\request.js:881:8)
    at ClientRequest.emit (events.js:400:28)
    at TLSSocket.socketErrorListener (_http_client.js:475:9)
    at TLSSocket.emit (events.js:400:28)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

@markhicken
Copy link

@markhicken markhicken commented Sep 30, 2021

Hi, Does any of the solution working for anyone? I tried all of the above suggested solutions, none of them worked for me. Any help would be appreciated.

Thanks

@saksham1211
I have a leetcode.com account that just uses my email (not 3rd party) and the cookie method works for me currently. While the cookie looks quite different, it still works.

leet-cookie

You have to copy the entire cookie string.

@saksham1211
Copy link

@saksham1211 saksham1211 commented Oct 1, 2021

Hi, Does any of the solution working for anyone? I tried all of the above suggested solutions, none of them worked for me. Any help would be appreciated.
Thanks

@saksham1211 I have a leetcode.com account that just uses my email (not 3rd party) and the cookie method works for me currently. While the cookie looks quite different, it still works.

leet-cookie

You have to copy the entire cookie string.

@markhicken Thank you so much for your response but it is not working for me. The screenshot which you shared, is it recent? because I am having different output in the Network tab.

@saksham1211
Copy link

@saksham1211 saksham1211 commented Oct 1, 2021

I am stuck at this point.

I have tried everything from changing endpoints to different login methods. None of them is working.

Below is the screenshot where I am stuck, using cookies login method, tried on both endpoints I am getting this output and it is stuck at this.
Anybody can help me on this?

Thanks in advance for taking out time and helping :)
image

@sam-brownlow
Copy link

@sam-brownlow sam-brownlow commented Oct 1, 2021

I am stuck at this point.

I have tried everything from changing endpoints to different login methods. None of them is working.

Below is the screenshot where I am stuck, using cookies login method, tried on both endpoints I am getting this output and it is stuck at this.
Anybody can help me on this?

Thanks in advance for taking out time and helping :)
image

This is still working

@markhicken
Copy link

@markhicken markhicken commented Oct 1, 2021

@markhicken Thank you so much for your response but it is not working for me. The screenshot which you shared, is it recent? because I am having different output in the Network tab.

Yes. I logged in this way yesterday. 🤷🏼

@saksham1211
Copy link

@saksham1211 saksham1211 commented Oct 1, 2021

Hi, Does any of the solution working for anyone? I tried all of the above suggested solutions, none of them worked for me. Any help would be appreciated.
Thanks

@saksham1211 I have a leetcode.com account that just uses my email (not 3rd party) and the cookie method works for me currently. While the cookie looks quite different, it still works.

You have to copy the entire cookie string.

@markhicken Thank you so much for your response but it is not working for me. The screenshot which you shared, is it recent? because I am having different output in the Network tab.

Yes. I logged in this way yesterday. 🤷🏼

@markhicken I am unable to log in, my cookie looks different than what you shared in the screenshot, even though I put my cookie, the output gets stuck in "Retrieving user information" and doesn't log in right away.

@laggardkernel
Copy link

@laggardkernel laggardkernel commented Oct 2, 2021

The prompt doesn't clarify what format do we need to input. There's no field starting with "__cfduid" or with "_gat=1" in the cookie these days.

Wasting 10 minutes browsing the post and finally I found the answer: cookies with the format of semicolon separated pairs. (You need all the cookies, not a single field)

Fuck leetcode-cli, you don't want it. Install EditThisCookie extension and change the export format and export the cookie. That's it.

@saksham1211
Copy link

@saksham1211 saksham1211 commented Oct 7, 2021

Hey,
How can I use leetcode extension behind corporate firewall? The cookies which I get on my corporate laptop is quite different than I get on my personal PC. Can somebody explain or suggest some workround?
Extension works fine on personal PC.
Thanks in advance for helping :)

@saurabh111121
Copy link

@saurabh111121 saurabh111121 commented Oct 24, 2021

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

+1

@agabekian
Copy link

@agabekian agabekian commented Oct 26, 2021

Just to confirm what worked for me, thanks to whoever posted the solution.

  1. Login to leetcode
  2. Open Chrome inspector -> Network -> Fetch/XHR.
  3. Click on some button in leetcode page, and in Inspector to the right under the "Name" tab find and select bottom "graphql" (that worked for me) and under Headers tab and in "Request Headers" portion, select and copy that whole massive cookie string.
  4. That's the cookie that got me in.
@arshappleid
Copy link

@arshappleid arshappleid commented Oct 28, 2021

Another update, the cookie feature only seems to be working on the US endpoint.
Atleast for me, or it may matter from which server(us/cn) that you get the cookie from.

@liuyuhang13
Copy link

@liuyuhang13 liuyuhang13 commented Dec 21, 2021

Just to confirm what worked for me, thanks to whoever posted the solution.

  1. Login to leetcode
  2. Open Chrome inspector -> Network -> Fetch/XHR.
  3. Click on some button in leetcode page, and in Inspector to the right under the "Name" tab find and select bottom "graphql" (that worked for me) and under Headers tab and in "Request Headers" portion, select and copy that whole massive cookie string.
  4. That's the cookie that got me in.

This works, thanks.

@ghostmiao5
Copy link

@ghostmiao5 ghostmiao5 commented Dec 21, 2021

@jiulun
Copy link

@jiulun jiulun commented Dec 23, 2021

Confirmed: cookie login works for US endpoint.
The key point is to copy the whole cookie, not just the string after the semicolon.

@EricESM
Copy link

@EricESM EricESM commented Jan 30, 2022

The prompt doesn't clarify what format do we need to input. There's no field starting with "__cfduid" or with "_gat=1" in the cookie these days.

Wasting 10 minutes browsing the post and finally I found the answer: cookies with the format of semicolon separated pairs. (You need all the cookies, not a single field)

Fuck leetcode-cli, you don't want it. Install EditThisCookie extension and change the export format and export the cookie. That's it.

this is the correct answer.

@ghostmiao5
Copy link

@ghostmiao5 ghostmiao5 commented Jan 30, 2022

@ceciliahangzhou
Copy link

@ceciliahangzhou ceciliahangzhou commented Feb 16, 2022

@saksham1211 Did you find a solution somehow?
I have the same issue with you and none of the above solutions works.
BTW, I am on macOS Monterey.
Can anyone help, please? Thank you so much

@ghostmiao5
Copy link

@ghostmiao5 ghostmiao5 commented Feb 16, 2022

@VinceCallocchia
Copy link

@VinceCallocchia VinceCallocchia commented Feb 20, 2022

@saksham1211 Did you find a solution somehow?
I have the same issue with you and none of the above solutions works.
BTW, I am on macOS Monterey.
Can anyone help, please? Thank you so much

On macOS Monterey using Safari ⬇️

  1. Login Leetcode (US).
  2. Right Click, select inspect element ("Show Dev Menu in menu bar" must be enabled)
  3. Click on Leetcode Logo on website header.
  4. Select "Network" tab, followed by XHR/Fetch.
  5. Select "graphql" on left, under "Header Request" copy entire cookie string.

In VScode 😎

  1. Open new terminal.
  2. Type "leetcode user -c"
  3. Type Username, hit return, then paste the cookie when prompted, hit return.
  4. Quit VScode, re-open application.

Screen Shot 2022-02-20 at 12 39 54 PM

@ceciliahangzhou
Copy link

@ceciliahangzhou ceciliahangzhou commented Feb 21, 2022

@saksham1211 Did you find a solution somehow?
I have the same issue with you and none of the above solutions works.
BTW, I am on macOS Monterey.
Can anyone help, please? Thank you so much

On macOS Monterey using Safari ⬇️

  1. Login Leetcode (US).
  2. Right Click, select inspect element ("Show Dev Menu in menu bar" must be enabled)
  3. Click on Leetcode Logo on website header.
  4. Select "Network" tab, followed by XHR/Fetch.
  5. Select "graphql" on left, under "Header Request" copy entire cookie string.

In VScode 😎

  1. Open new terminal.
  2. Type "leetcode user -c"
  3. Type Username, hit return, then paste the cookie when prompted, hit return.
  4. Quit VScode, re-open application.
Screen Shot 2022-02-20 at 12 39 54 PM

Thanks for your help.
However when I type in "leetcode user -c" there is an error and it is not working when try to type my username and cookie, check the screenshot.

Screen Shot 2022-02-21 at 1 03 08 PM

I also tried to use the username and cookie directly(the 4th option in below screenshot), so lucky either.

Screen Shot 2022-02-21 at 1 06 59 PM

@ghostmiao5
Copy link

@ghostmiao5 ghostmiao5 commented Feb 22, 2022

@VinceCallocchia
Copy link

@VinceCallocchia VinceCallocchia commented Feb 22, 2022

sorry,bro i still not solve this problem!!! But now i do leetcode in website!

Its ok bro it still works on my end. 👍
Screen Shot 2022-02-22 at 4 17 48 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment