🔑 Authentication Guide
To query problem details, list solved states, test code against judge servers, and submit solutions, leetrs requires authentication with LeetCode.com.
leetrs uses session cookies (LEETCODE_SESSION and csrftoken) to authenticate all API requests.
🔒 Interactive Auth (leetrs auth)
Run the interactive authentication command:
leetrs auth
You will see an interactive prompt powered by dialoguer:
🔒 LeetCode Authentication
? How would you like to authenticate?
❯ Paste tokens manually
Extract from Firefox
Extract from Chrome
🌐 Option 1: Automatic Cookie Extraction
If you are already logged into LeetCode in Chrome or Firefox, select:
Extract from FirefoxExtract from Chrome
leetrs uses the rookie crate to decrypt and extract active browser cookies without requiring browser extensions or external helpers.
- You must be logged into leetcode.com in the chosen browser.
- Close the browser if keyrings/databases are locked by exclusive file locks on Linux.
✍️ Option 2: Manual Token Fallback
If you are using containerized browsers (Snap / Flatpak), custom profile paths, Brave, Arc, or a headless server:
- Select
Paste tokens manually. - Open leetcode.com in your browser and open Developer Tools (
F12orCmd+Option+I). - Navigate to Application (Chrome) or Storage (Firefox) → Cookies →
https://leetcode.com. - Copy the values of:
LEETCODE_SESSIONcsrftoken
- Paste them into the interactive prompts in
leetrs auth.
🔍 Checking Authentication Status (leetrs status)
Verify your active credentials at any time:
leetrs status
Output:
✅ Currently authenticated!
🔑 csrftoken:
d9a8...f102
🔑 LEETCODE_SESSION:
eyJhbGciOi...
Credentials are saved in ~/.config/leetrs/credentials.json (or %APPDATA%\leetrs\credentials.json on Windows).