LeetCode VS Code Authy
VS Code extension:

Open VSX extension:

Firefox extension:

Chrome extension:

Solve LeetCode problems in VS Code using your signed-in leetcode.com browser session.
Important — Install Both Extensions: To work properly, you must install both on the same machine:
- This VS Code extension (VS Code Marketplace / Open VSX)
- The companion browser extension (Chrome Web Store / Firefox Add-ons)
Neither extension works fully on its own: the browser extension captures your authenticated leetcode.com session and request headers and syncs them locally to the VS Code extension.
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. This project is licensed under the GNU Affero General Public License v3.0. The original MIT license and copyright notices are preserved in LICENSE-MIT, with source attribution in NOTICE.md.
Visual Tour


Why Use It
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.com in 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.
Quick Start
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 choose Auto Cookie Sync.
- In the browser extension popup, click
Expire now, then open or refresh any leetcode.com page.
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.
Main Features
- 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.com endpoint.
- Click the
LeetCode: <username> status bar item to open a personal stats panel with solved counts, ranking, language stats, and recent accepted submissions.
- A second status bar item next to it shows browser session sync: just an icon while sync works, and a short warning such as
Sync stopped or Sync blocked when it needs you. Click it for sync details and the action that fixes the problem.
- Sync auth from Chrome, Chromium, or Firefox through the companion browser extension.
Core commands:
LeetCode: Sign In
LeetCode: Sign Out
LeetCode: Show User Profile
LeetCode: Search Problem
LeetCode: Pick One
LeetCode: Show Browser Auth Sync Status
LeetCode: Restart Browser Auth Sync Server
LeetCode: Session Sync Actions (same as clicking the session sync status bar item)
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 match leetcode.authSync.port in 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.
How Auth Sync Works
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.1 only. 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
/health and 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 now bypasses 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.secret is set, the browser extension must send the same value in the X-LeetCode-AuthSync-Secret header.
Security Note
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.
Settings
| Setting |
Default |
Description |
leetcode.hideSolved |
false |
Hide solved problems. |
leetcode.defaultLanguage |
N/A |
Default solution language. |
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 account and session sync status bar items. |
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. |
Local Development
Install dependencies:
npm ci --replace-registry-host=always
Common commands:
npm run compile
npm run bundle
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:chrome
npm run compile type-checks the TypeScript source. npm run bundle produces
the runtime entry and KaTeX webview assets under out/; packaging and the local
VS Code development command run both steps automatically. npm test also
verifies that the prospective VSIX contains the bundle and required assets,
without packaged node_modules.
Manual browser-extension loading:
- Chrome: open
chrome://extensions, enable Developer mode, click Load unpacked, and select browser-extension/.
- Firefox: open
about:debugging#/runtime/this-firefox, click Load Temporary Add-on, and select browser-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.com in that browser profile.
- In VS Code, choose
LeetCode: Sign In, then Auto Cookie Sync.
- In the browser extension popup, click
Expire now, then open or refresh any leetcode.com page.
- 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.
Requirements
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.
Help
Check the Troubleshooting and FAQ pages first. If the issue is still unresolved, file an issue.
Release Notes
See CHANGELOG.md.
Acknowledgement
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.