Solve LeetCode problems in VS Code with a companion browser extension that syncs your signed-in leetcode.com session to a local VS Code listener.
This independent project is maintained by wilmtang at wilmtang/leetcode-vscode-authy. It is not affiliated with, endorsed by, sponsored by, or published by LeetCode. The original MIT license and copyright notices are preserved in LICENSE, with source attribution in NOTICE.md.
Older LeetCode VS Code workflows can break when LeetCode changes auth, CSRF, or bot-protection behavior. This project keeps the workflow local and direct:
- No manual cookie copying: sign in to
leetcode.comin your browser, then sync that browser session into VS Code. - More reliable test and submit: VS Code reuses the synced cookie and captured browser request headers.
- Local-first sync: session data is posted only to the VS Code listener on
127.0.0.1. - Useful failure messages: auth-sync and Cloudflare failures surface as explicit sync/debug messages instead of generic login errors.
leetcode.cn support is currently broken and untested. Favorites and Solutions do not work on .cn after the move to direct API calls. Details live in docs/maintainer-guide.md.
Install both pieces on the same machine:
- Install LeetCode VS Code Authy from the VS Code Marketplace or Open VSX.
- Install the companion browser extension:
- Sign in to leetcode.com in that browser.
- In VS Code, open the LeetCode side bar, click
Sign In, and chooseAuto Cookie Sync. - In the browser extension popup, click
Expire now, then open or refresh anyleetcode.compage.
When sync succeeds, the VS Code notification closes, the LeetCode side bar refreshes, and test/submit commands use the same LeetCode session as your browser.
If a browser store listing is not available for your browser, load browser-extension/ manually from a local checkout. See Local Development.
- Browse, search, preview, and open LeetCode problems from the VS Code side bar.
- Generate local solution files under the configured workspace folder.
- Run tests and submit solutions from editor CodeLens shortcuts.
- Star and unstar problems on the validated
leetcode.comendpoint. - Click the
LeetCode: <username>status bar item to open a personal stats panel with solved counts, ranking, language stats, and recent accepted submissions. - Sync auth from Chrome, Chromium, or Firefox through the companion browser extension.
Core commands:
LeetCode: Sign InLeetCode: Sign OutLeetCode: Show User ProfileLeetCode: Search ProblemLeetCode: Pick OneLeetCode: Show Browser Auth Sync StatusLeetCode: Restart Browser Auth Sync Server
Browser extension controls:
Expire now: bypasses the cooldown for the next real LeetCode request.Cookie-only sync: optional advanced button that sends cookies immediately, without browser request headers.Enabled: turns browser-side sync on or off.Port: must matchleetcode.authSync.portin VS Code. Default:17899.Shared secret: optional. If set in VS Code, set the same value in the browser extension.Cooldown: controls how often automatic browser sync can run after a successful unchanged-session sync.
The browser extension does not log in to LeetCode by itself. It copies the already-signed-in browser session into VS Code over a loopback-only HTTP endpoint.
flowchart LR
A["You sign in on leetcode.com"] --> B["Browser extension reads LeetCode cookies"]
B --> C["POST http://127.0.0.1:17899/auth/update"]
C --> D["VS Code auth-sync server"]
D --> E["Session stored in VS Code secrets"]
E --> F["LeetCode explorer refreshes"]
E --> G["Browse, test, and submit use the synced session"]
Important details:
- The VS Code extension listens on
127.0.0.1only. Default endpoint:POST http://127.0.0.1:17899/auth/update. - The health endpoint is
GET http://127.0.0.1:17899/health. - If several VS Code windows are open, only one owns the listener. Other windows verify the live owner through
/healthand can take over when that listener is gone. - Automatic sync observes LeetCode XHR/fetch requests and respects the configured cooldown after a successful unchanged-session sync.
Expire nowbypasses the cooldown for the next real LeetCode request.- Cookie values are sent only to the local VS Code listener and are not intentionally logged.
- If
leetcode.authSync.secretis set, the browser extension must send the same value in theX-LeetCode-AuthSync-Secretheader.
leetcode.authSync.secret is empty by default for zero-config local sync. With no secret set, the listener accepts a request that reaches 127.0.0.1:<port> and carries a valid LeetCode session cookie, as long as it is not identified as a cross-site browser request.
That blocks ordinary malicious websites through the Origin/CORS checks, but it is not a boundary against another local process on the same machine. If you do not trust local processes or other local users, set leetcode.authSync.secret in VS Code and enter the same value in the browser extension settings.
| Setting | Default | Description |
|---|---|---|
leetcode.hideSolved |
false |
Hide solved problems. |
leetcode.defaultLanguage |
N/A |
Default solution language. |
leetcode.useWsl |
false |
Use WSL. |
leetcode.endpoint |
leetcode |
Active endpoint. leetcode-cn is currently broken in this project. |
leetcode.workspaceFolder |
"" |
Folder for generated problem files. |
leetcode.filePath |
"" |
Relative folder and filename pattern for problem files. |
leetcode.enableStatusBar |
true |
Show the LeetCode status bar item. |
leetcode.editor.shortcuts |
["submit, test"] |
Editor CodeLens shortcuts. |
leetcode.enableSideMode |
true |
Open preview, solution, and submission tabs in the second editor column. |
leetcode.showCommentDescription |
false |
Include problem descriptions in generated files. |
leetcode.useEndpointTranslation |
true |
Use endpoint translations when available. |
leetcode.colorizeProblems |
true |
Add difficulty badges and colors to problem files in the explorer. |
leetcode.problems.sortStrategy |
None |
Problem list sorting strategy. |
leetcode.allowReportData |
false |
Opt in to anonymous upstream telemetry. |
leetcode.authSync.enabled |
true |
Enable the local browser auth-sync server. |
leetcode.authSync.port |
17899 |
Local port used by the browser auth-sync server. |
leetcode.authSync.ownerHeartbeatIntervalSeconds |
30 |
Owner heartbeat interval. |
leetcode.authSync.observerCheckIntervalSeconds |
60 |
Observer health-check interval. |
leetcode.authSync.secret |
"" |
Optional shared secret required on browser auth-sync requests when set. |
Install dependencies:
npm ci --replace-registry-host=alwaysCommon commands:
npm run compile
npm test
npm run local -- vscode:dev
npm run local -- vscode:install
npm run local -- chrome:dev
npm run local -- chrome:dev-current
npm run auth-sync:lint:firefox
npm run auth-sync:build:firefox
npm run auth-sync:build:chromeManual browser-extension loading:
- Chrome: open
chrome://extensions, enable Developer mode, clickLoad unpacked, and selectbrowser-extension/. - Firefox: open
about:debugging#/runtime/this-firefox, clickLoad Temporary Add-on, and selectbrowser-extension/manifest.json.
End-to-end local smoke test:
- Start VS Code locally with
npm run local -- vscode:dev. - Start the browser extension with
npm run local -- chrome:dev, or load it manually. - Sign in to
https://leetcode.comin that browser profile. - In VS Code, choose
LeetCode: Sign In, thenAuto Cookie Sync. - In the browser extension popup, click
Expire now, then open or refresh anyleetcode.compage. - Confirm the VS Code waiting notification closes and the LeetCode explorer refreshes as signed in.
- Run a problem test or submit command to confirm the synced cookie works.
For the full local workflow, current caveats, audit notes, and release process, see docs/maintainer-guide.md.
No Node.js runtime is required for extension users. The extension talks to LeetCode directly over HTTP/GraphQL using your synced browser cookie. On the rare occasion LeetCode serves a Cloudflare challenge, the extension falls back to the system curl, which ships with macOS, Windows 10+, and most Linux distributions.
Check the Troubleshooting and FAQ pages first. If the issue is still unresolved, file an issue.
See CHANGELOG.md.
This extension originated from @jdneo's vscode-leetcode, which built on @skygragon's leetcode-cli. This project no longer bundles leetcode-cli; it talks to LeetCode directly using a synced browser cookie.
Special thanks to the project contributors.





