Skip to main content

Overview

Lichess uses OAuth2 for API authentication. You’ll need an OAuth token to:
  • Access private user data
  • Create games or challenges
  • Make moves as a bot
  • Manage account settings
Many API endpoints work without authentication. Only use OAuth when you need access to protected resources.

Creating an OAuth App

1

Register your application

Go to https://lichess.org/account/oauth/app and create a new OAuth app.Provide:
  • Name: Your application name (shown to users)
  • Description: What your app does
  • Redirect URI: Where users return after authorization
2

Get your credentials

After creating the app, you’ll receive:
  • Client ID: Public identifier for your app
  • Client Secret: Keep this confidential!
3

Choose your scopes

Request only the permissions your app needs. Available scopes are listed below.

OAuth Scopes

Scopes define what your app can access:
Request the minimum scopes needed. Users are more likely to authorize apps that request fewer permissions.

Authorization Code Flow

The standard OAuth2 flow for web applications:
1

Redirect user to authorization URL

Parameters:
  • response_type=code (required)
  • client_id - Your app’s client ID
  • redirect_uri - Must match your registered URI
  • scope - Space-separated scope list (URL encoded)
  • state - Random string to prevent CSRF attacks
2

User authorizes your app

Lichess shows the user what permissions you’re requesting. They can approve or deny.
3

Receive authorization code

User is redirected back to your app:
Verify the state parameter matches what you sent.
4

Exchange code for access token

POST to token endpoint:
Response:

Personal API Tokens

For personal scripts or testing, create a personal token:
  1. Go to https://lichess.org/account/oauth/token
  2. Select required scopes
  3. Click “Create”
  4. Copy your token (starts with lip_)
Personal tokens have full access to your account. Never share them or commit them to version control.

Using Access Tokens

Include the token in the Authorization header:

Token Expiration

  • OAuth tokens expire after 1 year by default
  • Personal tokens don’t expire unless revoked
  • Expired tokens return 401 Unauthorized
  • Request a new token when needed (no refresh tokens)

Revoking Tokens

Users can revoke your app’s access at https://lichess.org/account/oauth/token. When a token is revoked:
  • API requests return 401 Unauthorized
  • Your app should handle this gracefully
  • Prompt the user to re-authorize if needed

Security Best Practices

  • Never expose tokens in client-side code
  • Use environment variables or secure key storage
  • Encrypt tokens in your database
  • Never commit tokens to version control
  • Always use HTTPS for OAuth redirects
  • Never send tokens over unencrypted connections
  • Validate SSL certificates
  • Generate a random state value for each authorization request
  • Store it in the user’s session
  • Verify it matches when receiving the callback
  • This prevents CSRF attacks
  • Only request permissions you actually need
  • Users are more likely to approve limited access
  • Reduces damage if tokens are compromised

Testing

Use personal tokens for development:

Common Errors

Next Steps

API Overview

Learn about API structure and response formats

Rate Limits

Understand rate limiting policies

Bot API

Build a chess bot with OAuth

User Profile

Fetch authenticated user data