ctx7 auth commands manage authentication with Context7 for accessing authenticated features like skill generation and suggestions.
Subcommands
login
Log in to Context7
logout
Log out of Context7
whoami
Show current login status
login
Authenticate with Context7 using OAuth.Usage
Options
--no-browser
Don’t open the browser automatically. Displays the authentication URL for manual access.
How It Works
- Generate OAuth Parameters: Creates PKCE challenge and state parameter
- Open Browser: Opens Context7 login page (unless
--no-browseris used) - Wait for Callback: Starts local server to receive OAuth callback
- Exchange Code: Exchanges authorization code for access and refresh tokens
- Save Tokens: Stores tokens securely in
~/.context7/tokens.json
Examples
Standard Login
Manual Browser Login
- Running in SSH sessions
- Browser auto-open is not working
- Using a different browser than the system default
Already Logged In
logout
Log out of Context7 by clearing stored authentication tokens.Usage
Examples
Successful Logout
Not Logged In
whoami
Show your current authentication status and user information.Usage
Examples
Logged In
Not Logged In
Session Expired
Authentication Flow
OAuth with PKCE
Context7 uses OAuth 2.0 with PKCE (Proof Key for Code Exchange) for secure authentication:- Code Verifier: Random string generated locally
- Code Challenge: SHA-256 hash of the code verifier
- Authorization: User authorizes in browser
- Callback: Authorization code sent to local callback server
- Token Exchange: Code + verifier exchanged for tokens
- Storage: Tokens stored securely on local machine
Token Storage
Tokens are stored in:access_token: Used for API requestsrefresh_token: Used to obtain new access tokensexpires_at: Token expiration timestamp
Token Expiration
Access tokens expire after a period of time. When a token expires:- The CLI automatically uses the refresh token to get a new access token
- If the refresh token is also expired, you’ll be prompted to log in again
Authenticated Features
These features require authentication:Skill Generation
Enhanced Suggestions
Setup with Auto-Generated API Key
Account Tiers
Different account tiers provide different limits:| Feature | Free | Pro | Unlimited |
|---|---|---|---|
| Skill Search | ✓ | ✓ | ✓ |
| Skill Install | ✓ | ✓ | ✓ |
| Skill Suggestions | ✓ | ✓ | ✓ |
| Skill Generation | 3/week | 10/week | Unlimited |
| API Keys | 1 | 5 | Unlimited |
Upgrade your account at context7.com/dashboard
Troubleshooting
Login Failed
If login fails:- Check Internet Connection: Ensure you can access context7.com
- Try Again: Run
ctx7 loginagain - Manual URL: Use
ctx7 login --no-browserand copy the URL - Clear Tokens: Run
ctx7 logoutthenctx7 login
Port Already in Use
If the OAuth callback server can’t start:- Close applications using port 8080
- Try login again
- The CLI will automatically try alternative ports
Browser Doesn’t Open
If your browser doesn’t open automatically:- Use
ctx7 login --no-browser - Manually copy and open the URL shown
- Complete authentication in your browser
Token File Corrupted
If you see token-related errors:Permission Errors
If you can’t write tokens:Security Best Practices
Protect Your Tokens
- Never share
~/.context7/tokens.json - Don’t commit tokens to version control
- Use
ctx7 logouton shared machines - Regenerate tokens if compromised
API Keys vs OAuth
For MCP server configuration: OAuth (Recommended for personal use)Multiple Accounts
To switch accounts:Environment Variables
CONTEXT7_TOKEN
Override stored token with environment variable:
- CI/CD pipelines
- Automation scripts
- Testing