Open queensferryme opened 5 years ago
leetcode user -c
is showing [ERROR] You are not login yet?
. I installed most recent version of leetcode-cli.
How to run this command correctly?
@yhnedison
cli: leetcode-cli user -L (big L) to logout Delete default plugin from leetcode.cn cli: leetcode-cli plugin -d leetcode.cn(delete leetcode.cn) Change default to leetcode cli: leetcode-cli plugin -e leetcode
leetcode user -c
is showing[ERROR] You are not login yet?
. I installed most recent version of leetcode-cli. How to run this command correctly?
First use leetcode version
to see if you are using the latest version.
In the installation guide, note that the "From GitHub" Section gives another repo of leetcode-cli, whose master is 2.6.2. Uninstall your leetcode-cli and use npm install -g leetcode-tools/leetcode-cli
to install the latest version (2.6.17).
@yhnedison
- make sure you have installed latest version leetcode-cli which is 2.6.17
- check the plugin point that you are using leetcode not leetcode.cn
cli: leetcode-cli user -L (big L) to logout Delete default plugin from leetcode.cn cli: leetcode-cli plugin -d leetcode.cn(delete leetcode.cn) Change default to leetcode cli: leetcode-cli plugin -e leetcode
- leetcode-cli user -c
Thank you! It's working now!
For anyone wondering, please use https://github.com/leetcode-tools/leetcode-cli (instead of https://github.com/skygragon/leetcode-cli) and build from source to get 2.6.17 and follow the steps above.
Hi Guys, Thanks for the help!
I have been successfully login in command line, but in the vscode-leetcode, problem remains, still not able to get problems and coding in vscode, anyone knows how can I transfer the session to vscode-leetcode?
Nvm guys, I found the solution.
In case anyone has same issue, just go vscode settings -> extensions -> leetcode, then point your file location to your local installed leetcode-cli repo, and restart your vscode, you will be logged in by default since you have session on that folder I guess.
leetcode user -c
is showing[ERROR] You are not login yet?
. I installed most recent version of leetcode-cli. How to run this command correctly?First use
leetcode version
to see if you are using the latest version. In the installation guide, note that the "From GitHub" Section gives another repo of leetcode-cli, whose master is 2.6.2. Uninstall your leetcode-cli and usenpm install -g leetcode-tools/leetcode-cli
to install the latest version (2.6.17).
looks like this is not working, at least for me, I have to use git command to download the repo and install locally, npm give me file not exist error.
Hi Guys, Thanks for the help!
I have been successfully login in command line, but in the vscode-leetcode, problem remains, still not able to get problems and coding in vscode, anyone knows how can I transfer the session to vscode-leetcode?
Nvm guys, I found the solution.
In case anyone has same issue, just go vscode settings -> extensions -> leetcode, then point your file location to your local installed leetcode-cli repo, and restart your vscode, you will be logged in by default since you have session on that folder I guess.
Hi Nosense, I also logged into command line using cookies, but I didn't find any settings you mentioned "point your file location to your local installed leetcode-cli repo"
Can you please specify where should I input that leetcode-cli repo?? Thanks!
There is no VS Code setting pointing to the leetcode-cli repo.
If you want to install the leetcode-cli
with cookie login support, please run npm install -g vsc-leetcode-cli
If you want to use cookie login in VS Code, just wait for this PR merged and released. The ETA would be the end of this week.
It appears to me that even though I'm trying to login leetcode.com, it is trying to login into leetcode-cn.com with my userid and password!! Is this what this bug is about? or, I'm seeing something different? Where are the login details specified in the code? I would like to check that out
What information make you feeling that it is trying to login into leetcode-cn.com
Hi Guys, Thanks for the help! I have been successfully login in command line, but in the vscode-leetcode, problem remains, still not able to get problems and coding in vscode, anyone knows how can I transfer the session to vscode-leetcode? Nvm guys, I found the solution. In case anyone has same issue, just go vscode settings -> extensions -> leetcode, then point your file location to your local installed leetcode-cli repo, and restart your vscode, you will be logged in by default since you have session on that folder I guess.
Hi Nosense, I also logged into command line using cookies, but I didn't find any settings you mentioned "point your file location to your local installed leetcode-cli repo"
Can you please specify where should I input that leetcode-cli repo?? Thanks!
Hi, Vigoose
Click those red square area should lead you to the place.
What information make you feeling that
it is trying to login into leetcode-cn.com
Update: also, the signup pop-up goes to leetcode-cn.com; if it is the same variable storing the domain name in the code, it could be the case, that it didn't change, when I switch to leetcode.com from leetcode-cn.com. But I see above a solution is proposed, I will try that now
@jdneo Hi, I might be totally wrong on this, but while tinkering around, I noticed that, the leetcode-cn API's are active, even though if I set it to leetcode.com and not leetcode-cn.com If you confirm that you are confident that is not the case, I will trust you.
@nosensezzz Well, maybe it's working but I do not suggest to do that. This setting aims to point out the folder where you want to save your answers. Please remember to revert it back once we have released the fix.
One solution came up in my mind:
puppeteer-core
@yihong0618 Any ideas?
@jdneo I have tried the puppeteer way, but I failed. beacause the leetcode used Invisible Recaptcha which will test your score if the score not match it will cause a robot check. So I think use puppeteer-extre will be better.
And as I metioned that this way needs headless chrome(About 100MB). But I also think your puppeteer-signin way will work if puppeteer can get the cookie and save it to vscode. I will try it maybe on Sunday.
And I search many leetcode-projects on Github, for now using webview is someway to solve this. But vscode seems not support。
@yihong0618 I see. I'm not familiar in this area, not sure if this would gonna help.
What I'm thinking is, use puppeteer but not in headless mode, which means, the user needs to manually login in the pop-up browser window. The puppeteer is only used for popping up the browser window and getting the cookie once the user logins successfully. We won't used it to automatically fill the forms.
Will recaptcha detects this as bot action as well?
@jdneo puppeteer seems not support this way. I will research it.
@jdneo @lostindark
- I had tried to use puppeteer but using puppeteer will cause a rotbot check problem.
- 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
- 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 ):
This cookie but need to add some guide。
hi, may I ask where the "vscode input field" is? I pasted cookies to ~/.lc/leetcode/user.json, but can not login in vscode-leetcode.
@zhoujf620 There's no need to paste cookies to json
You can follow the steps
Update vscode-leetcode to the lastest version
Reload the vscode-leetcode
Command "ctrl + shift +p"(if mac "command + shift + p") then type leetcode sign in by cookie
Type click enter button May like this
@Cering There are two steps to get the cookie
- Login
- Call any api (such as click the problems button) not only get the leetcode session but also you need to get the csrf token. Because you have no csrf token you can only get the problems and your profile. As below:
this worked for me! thanks!!
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.
Make sure Node.js 8+ is installed. Instructions can be found on the official page
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+.
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"
Type leetcode user -c
from terminal within vscode. Follow the prompt and type in your username and cookie you copied above.
# to install the up-to-date version(2.6.17+) npm install -g leetcode-tools/leetcode-cli
@wuyifat Update vscode-leetcode and reload then "ctrl + shift + p" type sign in by cookie could work for now.
# to install the up-to-date version(2.6.17+) npm install -g leetcode-tools/leetcode-cli
@wuyifat Update vscode-leetcode and reload then "ctrl + shift + p" type sign in by cookie could work for now.
It did works now, great catch and response.
@lostindark Thank you for your idea. I have already found some way use OAuth2 for leetcode that leetcode can use third party login to avoid the Recaptcha to login. @jdneo I have a pr in leetcode-tools/leetcode-cli. Not only support third party--github login but also can avoid the Recaptcha and no need to copy the cookie in the browser.
@yihong0618 Wow, that would be perfect!!! Thank you!
@yihong0618 great thanks for that .
# to install the up-to-date version(2.6.17+) npm install -g leetcode-tools/leetcode-cli
@wuyifat Update vscode-leetcode and reload then "ctrl + shift + p" type sign in by cookie could work for now.
Nice! Confirmed in Win10
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.
- Make sure Node.js 8+ is installed. Instructions can be found on the official page
- 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+.
- 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"
- 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.
@LifeOfJona
@LifeOfJona
- Please check your vscode-leetcode is the latest version and reload it
- Type" Command + Shift + p or F1" then vscode will pop up an input
- Then type "Sign In by Cookie" you may see somthing like below
- Enter and maybe wait a little seconds (vscode-leetcode will load data) then type your account
- Paste your cookie from chrome or other
- Type Enter and wait for below
Thanks! It works for me. First I Sign In by Cookie and then use my username and password until I see your steps. I find I am wrong because it should use my cookie.
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.
- Make sure Node.js 8+ is installed. Instructions can be found on the official page
- 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+.
- 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"
- 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!!!!!
@LifeOfJona
- Please check your vscode-leetcode is the latest version and reload it
- Type" Command + Shift + p or F1" then vscode will pop up an input
- Then type "Sign In by Cookie" you may see somthing like below
- Enter and maybe wait a little seconds (vscode-leetcode will load data) then type your account
- Paste your cookie from chrome or other
- Type Enter and wait for below
After I input my account and password, it shows "login: login: cookie: [ERROR] invalid cookie?" . still failed.
@Aicius Please make sure you are using cookie that copy from browser not your password. About how to copy: please search from this issue.
Hi
I'm sure using the right cookiw in win10, but failed with error...
login: cookie: - Retrieving user favorites
[WARN] Failed to retrieve user favorites: Error: tunneling socket could not be established, cause=connect ECONNREFUSED 127.0.0.1:80
- Retrieving user profile
c:\Users\liyan\.vscode\extensions\shengchen.vscode-leetcode-0.15.8\node_modules\vsc-leetcode-cli\lib\log.js:55
let s = args.map(x => x.toString()).join(' ');
^
TypeError: Cannot read property 'toString' of undefined
at c:\Users\liyan\.vscode\extensions\shengchen.vscode-leetcode-0.15.8\node_modules\vsc-leetcode-cli\lib\log.js:55:31
at Array.map (<anonymous>)
at Object.log.<computed> [as info] (c:\Users\liyan\.vscode\extensions\shengchen.vscode-leetcode-0.15.8\node_modules\vsc-leetcode-cli\lib\log.js:55:20)
at c:\Users\liyan\.vscode\extensions\shengchen.vscode-leetcode-0.15.8\node_modules\vsc-leetcode-cli\lib\commands\user.js:81:11
at c:\Users\liyan\.vscode\extensions\shengchen.vscode-leetcode-0.15.8\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:528:14
at Request._callback (c:\Users\liyan\.vscode\extensions\shengchen.vscode-leetcode-0.15.8\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:427:19)
at self.callback (c:\Users\liyan\.vscode\extensions\shengchen.vscode-leetcode-0.15.8\node_modules\request\request.js:185:22)
at Request.emit (events.js:210:5)
at Request.onRequestError (c:\Users\liyan\.vscode\extensions\shengchen.vscode-leetcode-0.15.8\node_modules\request\request.js:881:8)
at ClientRequest.emit (events.js:210:5)
@liuyanfight I locate your problem, maybe you are using leetcode-cn.
And I think I can change leetcode-cn in up-stream repo in the future to make the log more clear
@liuyanfight I locate your problem, maybe you are using leetcode-cn.
- If you are using leetcode-cn account to login there is no need to cookie login, just use your cn account to login is fine.
- If you are using leetcode.com account to login you have to change your endpoint from leetcode.cn to leetcode first.
- then follow the steps to cookie login
And I think I can change leetcode-cn in up-stream repo in the future to make the log more clear
Same problem. It works.
@Aicius Please make sure you are using cookie that copy from browser not your password. About how to copy: please search from this issue.
Hello, there are 6 different cookies? Which one to choose? Is it just past the content?
es? Which one to choose? Is it just past
the whole content.
es? Which one to choose? Is it just past
the whole content.
I want to ask which one of these 6 cookies to choose from...
@Aicius you dont have to choose one just take all of them and paste it
@liuyanfight I locate your problem, maybe you are using leetcode-cn.
- If you are using leetcode-cn account to login there is no need to cookie login, just use your cn account to login is fine.
- If you are using leetcode.com account to login you have to change your endpoint from leetcode.cn to leetcode first.
- then follow the steps to cookie login
And I think I can change leetcode-cn in up-stream repo in the future to make the log more clear
Same problem. It works. I still have the problem ?? I changed the endpoint in vscode by choosing leetcode.com using pickone option. Am I missing something, could you please elaborate?
@Aicius you dont have to choose one just take all of them and paste it
What do you mean by take all of them... I copy the content one by one and then copy & paste together but it doesn't work
any workaround for new installations? I just installed the leetcode extension and seems that there is no cookie info
thanks. @yihong0618 It works for me.
@jdneo @lostindark
- I had tried to use puppeteer but using puppeteer will cause a rotbot check problem.
- 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
- 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 ):
This cookie but need to add some guide。
It works for me, thanks! To be more clear, the cookie is the entire String marked in Red in the pic.
Then, In leetcode VS Code, Ctrl + Shift + P, choose, log in with cookie. Your Username, The copied Cookies. Enter!
We now support Cookie login, third-party login (GitHub, LinkedIn)
This problem should be mitigated now.
it should be mentioned,the cookie is captured in the request header when you clicks a button to send a request to leetcode.com.
I have tried third-party login (Github), but it failed, I guess due to 2FA enabled on Github account.
2FA
@DukeXar 2FA support~ Did you have any error message?
@yihong0618, have just reproduced - I don't see any details in console:
[ERROR] You are not login yet?
login: pass: [ERROR] Login failed. Please make sure the credential is correct.
In the security logs of Github it was visible that 2FA was requested at the same time I was logging into the extension.
I have also checked that disabling 2FA allows to log in into the extension using Github provider.
🐛 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
Your Environment