vscode-leetcode
vscode-leetcode copied to clipboard
TypeError: cb is not a function
🐛 Bug Report
login by username and cookie
To Reproduce
Steps to reproduce the behavior.
Expected behavior
A clear and concise description of what you expected to happen.
Extension Output
login: cookie: /Users/otis.z/.vscode/extensions/shengchen.vscode-leetcode-0.16.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:555
return cb('invalid cookie?');
^
TypeError: cb is not a function
at parseCookie (/Users/otis.z/.vscode/extensions/shengchen.vscode-leetcode-0.16.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:555:12)
at Plugin.plugin.cookieLogin (/Users/otis.z/.vscode/extensions/shengchen.vscode-leetcode-0.16.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:578:22)
at /Users/otis.z/.vscode/extensions/shengchen.vscode-leetcode-0.16.1/node_modules/vsc-leetcode-cli/lib/commands/user.js:119:12
at /Users/otis.z/.vscode/extensions/shengchen.vscode-leetcode-0.16.1/node_modules/prompt/lib/prompt.js:336:32
at /Users/otis.z/.vscode/extensions/shengchen.vscode-leetcode-0.16.1/node_modules/utile/node_modules/async/lib/async.js:154:25
at assembler (/Users/otis.z/.vscode/extensions/shengchen.vscode-leetcode-0.16.1/node_modules/prompt/lib/prompt.js:333:9)
at /Users/otis.z/.vscode/extensions/shengchen.vscode-leetcode-0.16.1/node_modules/prompt/lib/prompt.js:342:32
at /Users/otis.z/.vscode/extensions/shengchen.vscode-leetcode-0.16.1/node_modules/prompt/lib/prompt.js:625:5
at Interface.onLine (/Users/otis.z/.vscode/extensions/shengchen.vscode-leetcode-0.16.1/node_modules/read/lib/read.js:111:5)
at Interface.emit (events.js:198:13)
Guidance: Press Ctrl+Shift+U
, and toggle the channel to LeetCode
.
Your Environment
- os: MacOS 10.15
-
extension settings:
- "leetcode.nodePath": "/usr/local/bin/node"
- "leetcode.endpoint": "leetcode-cn"
- "leetcode.defaultLanguage": "java"
- nodejs version: v10.16.0
- vscode version: 1.42
- extension version: 0.16.1
for anyone having this problem, until it fixed, here is a workaround...
Terminal:
# Get leetcode CLI tools
npm install -g skygragon/leetcode-cli
# Create and open user.json file
cd ~/.lc/leetcode/user.json && code user.json
user.json
:
// Enter login credentials to user.json
// From browser, login to leetcode, then Dev tools -> Application -> Cookies
// You would need LEETCODE_SESSION and csrftoken
{
"login": "", //username
"sessionCSRF": "", //paste "csrftoken"
"sessionId": "", //paste "LEETCODE_SESSION"
}
Restart vscode, and you should be logged in.
for anyone having this problem, until it fixed, here is a workaround...
Terminal:
# Get leetcode CLI tools npm install -g skygragon/leetcode-cli # Create and open user.json file cd ~/.lc/leetcode/user.json && code user.json
user.json
:// Enter login credentials to user.json // From browser, login to leetcode, then Dev tools -> Application -> Cookies // You would need LEETCODE_SESSION and csrftoken { "login": "", //username "sessionCSRF": "", //paste "csrftoken" "sessionId": "", //paste "LEETCODE_SESSION" }
Restart vscode, and you should be logged in.
I tried but it didn't work for me
for anyone having this problem, until it fixed, here is a workaround...
Terminal:
# Get leetcode CLI tools npm install -g skygragon/leetcode-cli # Create and open user.json file cd ~/.lc/leetcode/user.json && code user.json
user.json
:// Enter login credentials to user.json // From browser, login to leetcode, then Dev tools -> Application -> Cookies // You would need LEETCODE_SESSION and csrftoken { "login": "", //username "sessionCSRF": "", //paste "csrftoken" "sessionId": "", //paste "LEETCODE_SESSION" }
Restart vscode, and you should be logged in.
Work for me, thanks!
for anyone having this problem, until it fixed, here is a workaround...
Terminal:
# Get leetcode CLI tools npm install -g skygragon/leetcode-cli # Create and open user.json file cd ~/.lc/leetcode/user.json && code user.json
user.json
:// Enter login credentials to user.json // From browser, login to leetcode, then Dev tools -> Application -> Cookies // You would need LEETCODE_SESSION and csrftoken { "login": "", //username "sessionCSRF": "", //paste "csrftoken" "sessionId": "", //paste "LEETCODE_SESSION" }
Restart vscode, and you should be logged in.
Thanks! It work.
thanks
@BatuhanKorur Thanks a lot!
for anyone having this problem, until it fixed, here is a workaround...
Terminal:
# Get leetcode CLI tools npm install -g skygragon/leetcode-cli # Create and open user.json file cd ~/.lc/leetcode/user.json && code user.json
user.json
:// Enter login credentials to user.json // From browser, login to leetcode, then Dev tools -> Application -> Cookies // You would need LEETCODE_SESSION and csrftoken { "login": "", //username "sessionCSRF": "", //paste "csrftoken" "sessionId": "", //paste "LEETCODE_SESSION" }
Restart vscode, and you should be logged in.
c:\Users\lxcx.vscode\extensions\leetcode.vscode-leetcode-0.17.0\node_modules\vsc-leetcode-cli\lib\commands\user.js:146 "login": "[email protected]", //username ^
SyntaxError: Unexpected token ':'
at wrapSafe (internal/modules/cjs/loader.js:1053:16)
at Module._compile (internal/modules/cjs/loader.js:1101:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at Object.require (internal/modules/cjs/helpers.js:72:18)
at c:\Users\lxcx.vscode\extensions\leetcode.vscode-leetcode-0.17.0\node_modules\require-directory\index.js:76:17
at Array.forEach (
I can't understand this question...:(
code ~/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js
sessionId is cookie.LEETCODE_SESSION
in devtools application panel.
sessionCSRF is cookie.csrftoken
in devtools application panel.
find line 541, follow above step. Restart, login success!
code ~/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js
sessionId is
cookie.LEETCODE_SESSION
in devtools application panel. sessionCSRF iscookie.csrftoken
in devtools application panel.find line 541, follow above step. Restart, login success!
it works, obviously. but it feels too weird to have to resort to such measures...
code ~/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js
sessionId is
cookie.LEETCODE_SESSION
in devtools application panel. sessionCSRF iscookie.csrftoken
in devtools application panel.find line 541, follow above step. Restart, login success!
It works, Thank you!
The actual reason is that leetcode is not sending LEETCODE_SESSION and sessionCSRF in all the HTTP requests. It is only included in the graphql requests.
Using the cookie from https://leetcode.com/graphql/
request would work without changing anything in the plugin.
The actual reason is that leetcode is not sending LEETCODE_SESSION and sessionCSRF in all the HTTP requests. It is only included in the graphql requests.
Using the cookie from
https://leetcode.com/graphql/
request would work without changing anything in the plugin.
Using the cookie from https://leetcode.com
or https://leetcode.com/graphql
. Both cookies work for me.