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 · 265 comments
Open

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

queensferryme opened this issue Nov 23, 2019 · 265 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@queensferryme
Copy link

🐛 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

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

image

@eeliu
Copy link

eeliu commented Nov 23, 2019

+1

@eeliu
Copy link

eeliu commented Nov 23, 2019

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

@mpirbhoy
Copy link

+1

@zhoujf620
Copy link

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 commented Nov 24, 2019

same issue

@BaccanoEva
Copy link

+1

@jdneo jdneo added the help wanted Extra attention is needed label Nov 25, 2019
@qiwei9743
Copy link

+1

1 similar comment
@Kalyan-M
Copy link

+1

@yihong0618
Copy link
Contributor

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

+1

@Vigoose
Copy link

Vigoose commented Nov 25, 2019

same issue

@LincolnZeng
Copy link

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

@zzjoey
Copy link

zzjoey commented Nov 26, 2019

+1, the same issue.

@oasis10702
Copy link

+1, same issue

@Holybasil
Copy link

same

@jdneo
Copy link
Member

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

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 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

+1

@CoolersCoder
Copy link

@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

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

@lostindark
Yes, Also cause the check robot, and it seems that it counts your score to test if you are human.
Then I gave up this method.

@starrye
Copy link

starrye commented Nov 27, 2023

leetcode 2.8.0版本无法登录

/Users/admin/.nvm/versions/node/v14.15.1/lib/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:519
        user.paid = _user.isCurrentUserPremium;
                          ^

TypeError: Cannot read property 'isCurrentUserPremium' of null
    at /Users/admin/.nvm/versions/node/v14.15.1/lib/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:519:27
    at Request._callback (/Users/admin/.nvm/versions/node/v14.15.1/lib/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:425:12)
    at Request.self.callback (/Users/admin/.nvm/versions/node/v14.15.1/lib/node_modules/vsc-leetcode-cli/node_modules/request/request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.<anonymous> (/Users/admin/.nvm/versions/node/v14.15.1/lib/node_modules/vsc-leetcode-cli/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:315:20)
    at IncomingMessage.<anonymous> (/Users/admin/.nvm/versions/node/v14.15.1/lib/node_modules/vsc-leetcode-cli/node_modules/request/request.js:1083:12)

+1

@yihan12
Copy link

yihan12 commented Dec 5, 2023

image

《csrftoken="xyz"; LEETCODE_SESSION="xyz";》 Can solve this problem

@DaKe-Zhang
Copy link

DaKe-Zhang commented Dec 10, 2023

I was able to use the Cookie way to log in.

I don't know why it's not working last time. But this morning I tried it with my email and the cookie with the format of:

csrftoken="xyz";LEETCODE_SESSION="xyz";

Hope this will help.

@foal20ym
Copy link

I can confirm that it is possible to log in by entering your email and the cookie in the format of:
csrftoken='xyz'; LEETCODE_SESSION='xyz';
as of Wednesday, December 13th, 2023.
Thank you to everyone who figured it out.

@starrye
Copy link

starrye commented Dec 18, 2023

it's still not working , i tried it with my email and the cookie with the format of:
csrftoken="xyz";LEETCODE_SESSION="xyz";

user.paid = _user.isCurrentUserPremium; 
                         
TypeError: Cannot read properties of null (reading 'isCurrentUserPremium')

@Dzy0726
Copy link

Dzy0726 commented Dec 27, 2023

it's still not working , i tried it with my email and the cookie with the format of: csrftoken="xyz";LEETCODE_SESSION="xyz";

user.paid = _user.isCurrentUserPremium; 
                         
TypeError: Cannot read properties of null (reading 'isCurrentUserPremium')

+1

@Soulike
Copy link

Soulike commented Dec 28, 2023

Can not login with cookies.

cookie: - Retrieving user favorites
[WARN] Failed to retrieve user favorites: [object Object]
- Retrieving user profile
/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:31
    at Array.map (<anonymous>)
    at log.<computed> [as info] (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:20)
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/commands/user.js:121:13
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:523:14
    at Request._callback (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:422:19)
    at self.callback (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:185:22)
    at Request.emit (node:events:514:28)
    at Request.<anonymous> (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:514:28)

Node.js v20.10.0

@chagantibhaskar
Copy link

Can not login with cookies.

cookie: - Retrieving user favorites
[WARN] Failed to retrieve user favorites: [object Object]
- Retrieving user profile
/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:31
    at Array.map (<anonymous>)
    at log.<computed> [as info] (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:20)
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/commands/user.js:121:13
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:523:14
    at Request._callback (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:422:19)
    at self.callback (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:185:22)
    at Request.emit (node:events:514:28)
    at Request.<anonymous> (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:514:28)

Node.js v20.10.0

Same here. It was working till afternoon, but suddenly stopped working from evening. Please let me know if you were able to find a workaround.

@fakhriaunur
Copy link

fakhriaunur commented Dec 28, 2023

Can not login with cookies.

cookie: - Retrieving user favorites
[WARN] Failed to retrieve user favorites: [object Object]
- Retrieving user profile
/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:31
    at Array.map (<anonymous>)
    at log.<computed> [as info] (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:20)
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/commands/user.js:121:13
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:523:14
    at Request._callback (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:422:19)
    at self.callback (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:185:22)
    at Request.emit (node:events:514:28)
    at Request.<anonymous> (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:514:28)

Node.js v20.10.0

Same here. It was working till afternoon, but suddenly stopped working from evening. Please let me know if you were able to find a workaround.

I'm having the same difficulties, but it's working again as of right now

@zsyc
Copy link

zsyc commented Jan 16, 2024

If you use chromium-based browsers there's this extension I made that you can use to copy cookies: https://chromewebstore.google.com/detail/vsleet/ihgifhobfmjhcelknpbjhpabkcghjmfh?hl=en

#478 (comment)

It works, thanks!
I still don't understand why it gets the different cookies than I get from browser developer mode. But the cookies it gets works fine and I logged in in VS-code smoothly.

@ghostmiao5
Copy link

ghostmiao5 commented Jan 16, 2024 via email

@amywang94087
Copy link

Why don't just watch this https://www.youtube.com/watch?v=zNOJWXZ3i_Q
after did this, close all VS code window, restart VS code!

@ghostmiao5
Copy link

ghostmiao5 commented Feb 10, 2024 via email

@tangweize
Copy link

Can not login with cookies.

cookie: - Retrieving user favorites
[WARN] Failed to retrieve user favorites: [object Object]
- Retrieving user profile
/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:31
    at Array.map (<anonymous>)
    at log.<computed> [as info] (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:20)
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/commands/user.js:121:13
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:523:14
    at Request._callback (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:422:19)
    at self.callback (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:185:22)
    at Request.emit (node:events:514:28)
    at Request.<anonymous> (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:514:28)

Node.js v20.10.0

Same here. It was working till afternoon, but suddenly stopped working from evening. Please let me know if you were able to find a workaround.

image try to change to 国内版

@cxlhyx
Copy link

cxlhyx commented Feb 21, 2024

我发现了一个适合我的解决方法。我注意到 vscode-leetcode 现在使用 vsc-leetcode-cli,当我们使用“Leetcode Cookie”选项登录时,它仅解析并使用输入 cookie 字符串中的“LEETCODE_SESSION”和“csrftoken”。图像所以我只输入一个最小的自定义cookie字符串来登录,例如:“LEETCODE_SESSION=xxxxxxxxx;csrftoken=xxxxx;”,当我们使用浏览器访问 leetcode.com 时,我们可以在浏览器开发工具的“应用程序”选项卡下的存储 cookie 中找到“LEETCODE_SESSION”和“csrftoken”的值。图像

嗨,我也有这个问题。你能给出一个更详细的方法吗?

刷新页面。转到开发人员选项中的“网络”选项卡。选择 Fetch/XHR。在 names 部分下,选择任何 graphql req/res。转到请求标头部分。在那里找到 cookie 密钥。仅选择 cookie 值的这一部分 -> csrftoken=“xyz”;LEETCODE_SESSION=“xyz”;打开终端,键入 leetcode user -c 输入用户名和此 cookie 值。

这对我有用。谢谢

谢谢,这通过一个额外的步骤为我工作,所以任何人都可以尝试这个,按照上述步骤操作,在 leetcode user -c 命令之后,输入然后写成 username csrftoken=“xyz”;LEETCODE_SESSION=“xyz”;在此之后,它再次向我索要 cookie,然后再次编写同样的东西,它会起作用。

helpful

@mangyuan-coding
Copy link

Can not login with cookies.

cookie: - Retrieving user favorites
[WARN] Failed to retrieve user favorites: [object Object]
- Retrieving user profile
/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:31
    at Array.map (<anonymous>)
    at log.<computed> [as info] (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:20)
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/commands/user.js:121:13
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:523:14
    at Request._callback (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:422:19)
    at self.callback (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:185:22)
    at Request.emit (node:events:514:28)
    at Request.<anonymous> (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:514:28)

Node.js v20.10.0

Same here. It was working till afternoon, but suddenly stopped working from evening. Please let me know if you were able to find a workaround.

I'm having the same difficulties, but it's working again as of right now

same

@ghostmiao5
Copy link

ghostmiao5 commented Mar 7, 2024 via email

@Reilkay
Copy link

Reilkay commented Mar 7, 2024

Can not login with cookies.无法使用cookie登录。

cookie: - Retrieving user favorites
[WARN] Failed to retrieve user favorites: [object Object]
- Retrieving user profile
/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:31
    at Array.map (<anonymous>)
    at log.<computed> [as info] (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:20)
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/commands/user.js:121:13
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:523:14
    at Request._callback (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:422:19)
    at self.callback (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:185:22)
    at Request.emit (node:events:514:28)
    at Request.<anonymous> (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:514:28)

Node.js v20.10.0

Same here. It was working till afternoon, but suddenly stopped working from evening. Please let me know if you were able to find a workaround.同样在这里。它一直工作到下午,但从晚上突然停止工作。如果您能够找到解决方法,请告诉我。

I'm having the same difficulties, but it's working again as of right now我遇到了同样的困难,但截至目前,它又开始工作了

same 相同

same question, it was working fine in yesterday, but when I try to use this plugin today, it just cannot login.

@Sober7135
Copy link

Can not login with cookies.

cookie: - Retrieving user favorites
[WARN] Failed to retrieve user favorites: [object Object]
- Retrieving user profile
/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:31
    at Array.map (<anonymous>)
    at log.<computed> [as info] (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:20)
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/commands/user.js:121:13
    at /Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:523:14
    at Request._callback (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:422:19)
    at self.callback (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:185:22)
    at Request.emit (node:events:514:28)
    at Request.<anonymous> (/Users/soulike/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:514:28)

Node.js v20.10.0

Same here. It was working till afternoon, but suddenly stopped working from evening. Please let me know if you were able to find a workaround.

I'm having the same difficulties, but it's working again as of right now

same

same question. It worked yesterday, but not today

@hakula139
Copy link

After adding some logs, it seems that the login requests are blocked by Cloudflare's JS Challenge. Have tried changing IPs and adding headers like User-Agent, but still not working. Perhaps it's related to some Cloudflare specified cookies to check if the request is from a browser or a script, not sure what to do next.

@yuangu002
Copy link

I was able to use the Cookie way to log in.

I don't know why it's not working last time. But this morning I tried it with my email and the cookie with the format of:

csrftoken="xyz";LEETCODE_SESSION="xyz";

Hope this will help.

Anyone successfully login recently? I tried the approach but still the same error:

[WARN] Failed to retrieve user favorites: [object Object]
- Retrieving user profile
/Users/yuangu/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^
TypeError: Cannot read properties of undefined (reading 'toString')
    at /Users/yuangu/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:31
    at Array.map (<anonymous>)
    at log.<computed> [as info] (/Users/yuangu/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:20)
    at /Users/yuangu/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/commands/user.js:121:13
    at /Users/yuangu/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:523:14
    at Request._callback (/Users/yuangu/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:422:19)
    at self.callback (/Users/yuangu/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:185:22)
    at Request.emit (node:events:513:28)
    at Request.<anonymous> (/Users/yuangu/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:513:28)

Node.js v18.6.0

@SharnavM
Copy link

I tried this, and it worked.

#927 (comment)

@ams765
Copy link

ams765 commented Mar 18, 2024

can't login leetcode version 2.8.0

/Users/admin/.nvm/versions/node/v14.15.1/lib/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:519
        user.paid = _user.isCurrentUserPremium;
                          ^

TypeError: Cannot read property 'isCurrentUserPremium' of null
    at /Users/admin/.nvm/versions/node/v14.15.1/lib/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:519:27
    at Request._callback (/Users/admin/.nvm/versions/node/v14.15.1/lib/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:425:12)
    at Request.self.callback (/Users/admin/.nvm/versions/node/v14.15.1/lib/node_modules/vsc-leetcode-cli/node_modules/request/request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.<anonymous> (/Users/admin/.nvm/versions/node/v14.15.1/lib/node_modules/vsc-leetcode-cli/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:315:20)
    at IncomingMessage.<anonymous> (/Users/admin/.nvm/versions/node/v14.15.1/lib/node_modules/vsc-leetcode-cli/node_modules/request/request.js:1083:12)

was having this problem but this solution worked

image

《csrftoken="xyz"; LEETCODE_SESSION="xyz";》 Can solve this problem

just copy and paste csrftoken="xyz"; LEETCODE_SESSION="xyz"; somewhere else then go grab the two cookie values and replace xyz with them. after that copy the entire thing and use it as cookie login

@Venkat2552004
Copy link

Here to say that this method is still working in July 2024, Thanks for the solution...!

@ghostmiao5
Copy link

ghostmiao5 commented Jul 14, 2024 via email

@ali-soomro
Copy link

I JUST managed to get it working (1st September 2024 right now) and did NOT use the cookie method.
I tried the "recommended" method of just logging in, after multiple attempts of the cookie method.

My cookies were correct, as I was able to send a curl request and it returned my username (using the following command):

curl 'https://leetcode.com/graphql' \ -H 'Content-Type: application/json' \ -H 'Cookie: csrftoken=hidden; LEETCODE_SESSION=hidden \ -H 'x-csrftoken: hidden \ -d '{"query": "{ user { username } }"}'

Note, now I've got a new problem, which is code completion does not work at all.

Here is a screenshot as proof:
Screenshot 2024-09-01 at 00 41 14

@ghostmiao5
Copy link

ghostmiao5 commented Aug 31, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests