LeetCode Login in VS Code

2023/07/08

LeetCode is good, but its online IDE isn’t. It slows me down often when I’m focusing on algorithm implementations. Instead, the need to memorize countless syntax details to ensure runnable code often distracts me from the core challenge. Outside LeetCode, I usually program on Visual Studio Code, which is powerful with the support of IntelliSense and Copilot. So, if you ever had the same feelings like me, you should definitely try this LeetCode extension in VS Code provided by LeetCode China.

Problem

This article is to record a solution that addresses the login problem of global accounts (leetcode.com) when using this extension. Feel free to skip ahead if your account is already on leetcode.cn (previously leetcode-cn.com).

Recently, attempting to log into LeetCode via the extension, whether through a direct account and password or a third-party account, triggers a pop-up and terminal notification that indicate failure. Then I generalized a temporary solution from this post.

Solution

Step 1: Open leetcode.com

Step 2: Open Inspect in Browser

For Mac, press Command + Shift + C.
For Windows, press Control + Shift + C.
Or you can right-click and choose Inspect.

Click Network on the menu bar. It should be blank at first, but will show a list of network requests after you refresh the web page.

Choose any of them from the list whose request URL is under the domain of leetcode.com, say home/.

Scroll down to find Cookie under Request Headers. Select and copy it.

Step 3: Open VS Code

On this login interface, choose LeetCode Cookie.

Paste the cookie you got from step 2 here. Then you’ll see a success notification at the bottom-right corner of VS Code.

Congratulations!