When Authentication is Required
Authentication is needed for:- Creating data - Creating projects, versions, reports, etc.
- Modifying data - Editing project metadata, updating versions, etc.
- Accessing private data - Draft projects, notifications, emails, payout data
- User-specific operations - Managing collections, following projects, etc.
Most read operations (viewing public projects, searching, downloading files) do not require authentication.
Personal Access Tokens
Personal Access Tokens (PATs) are the recommended authentication method for server-side applications and scripts.Creating a PAT
- Log in to modrinth.com
- Navigate to Settings > Account
- Scroll to the Personal Access Tokens section
- Click Create a token
- Enter a token name and select the required scopes
- Click Create and copy your token immediately
Using a PAT
Include your token in theAuthorization header:
Token Format
PATs always start with the prefixmrp_ (Modrinth Personal Token):
Managing PATs
You can manage your tokens at any time:- View tokens: See all active tokens and their last used date
- Revoke tokens: Immediately invalidate a token
- Update scopes: Create a new token with different permissions
OAuth 2.0
OAuth 2.0 is the recommended method for client-side applications that act on behalf of users.OAuth Flow Overview
- Create an OAuth Application in your Modrinth account settings
- Redirect users to Modrinth’s authorization page
- Receive authorization code via callback
- Exchange code for access token
- Make authenticated requests using the access token
Creating an OAuth Application
- Navigate to Settings > Applications
- Click Create an application
- Fill in:
- Name: Your application name
- Description: What your app does
- Redirect URIs: Allowed callback URLs (one per line)
- Max Scopes: Maximum permissions your app can request
- Click Create and note your Client ID and Client Secret
Step 1: Initiate Authorization
Redirect users to Modrinth’s authorization endpoint:client_id(required): Your OAuth application’s client IDredirect_uri(required): Must match a registered redirect URIscope(optional): Space or+separated list of scopes (defaults to app’s max scopes)state(recommended): Random string to prevent CSRF attacks
Step 2: Handle the Callback
After the user authorizes your app, they’re redirected to your callback URL:Step 3: Exchange Code for Token
Exchange the authorization code for an access token:Step 4: Use the Access Token
Use the access token in theAuthorization header:
mro_ (Modrinth OAuth).
Token Refresh
OAuth tokens expire after a period of time. When a token expires, you’ll receive a401 Unauthorized response. Users must re-authorize to obtain a new token.
Scopes and Permissions
Both PATs and OAuth tokens use scopes to limit permissions. Request only the scopes your application needs.Available Scopes
User Scopes
User Scopes
USER_READ: Read user profile dataUSER_READ_EMAIL: Read user email addressUSER_WRITE: Update user profile (username, avatar, bio, etc.)USER_DELETE: Delete user account (PAT only, not available via OAuth)USER_AUTH_WRITE: Modify authentication settings (PAT only)
Project Scopes
Project Scopes
PROJECT_CREATE: Create new projectsPROJECT_READ: Read user’s projects (including private/draft)PROJECT_WRITE: Edit project metadata, team members, settingsPROJECT_DELETE: Delete projects
Version Scopes
Version Scopes
VERSION_CREATE: Upload new versionsVERSION_READ: Read user’s versions (including private/draft)VERSION_WRITE: Edit version metadata and filesVERSION_DELETE: Delete versions
Notification Scopes
Notification Scopes
NOTIFICATION_READ: Read user notificationsNOTIFICATION_WRITE: Mark notifications as read or delete them
Collection Scopes
Collection Scopes
COLLECTION_CREATE: Create collectionsCOLLECTION_READ: Read user’s collections (including private)COLLECTION_WRITE: Edit collectionsCOLLECTION_DELETE: Delete collections
Analytics & Payouts
Analytics & Payouts
ANALYTICS: Access analytics dataPAYOUTS_READ: Read payout informationPAYOUTS_WRITE: Withdraw fundsPERFORM_ANALYTICS: Submit analytics events
Other Scopes
Other Scopes
REPORT_CREATE: Create reportsREPORT_READ: Read user’s reportsTHREAD_READ: Read message threadsTHREAD_WRITE: Send messages in threadsORGANIZATION_CREATE: Create organizationsORGANIZATION_READ: Read user’s organizationsORGANIZATION_WRITE: Edit organizations
Scope Format
In OAuth URLs, separate scopes with spaces or+:
Restricted Scopes
Some scopes are restricted and cannot be used in PATs:USER_DELETEUSER_AUTH_WRITEPAT_CREATE,PAT_READ,PAT_WRITE,PAT_DELETESESSION_READ,SESSION_DELETE,SESSION_ACCESS
Token Security Best Practices
Storage
- Server-side: Store in environment variables or secure credential management systems
- Client-side: Store OAuth tokens in secure, HttpOnly cookies or encrypted storage
- Never commit tokens to version control
Transmission
- Always use HTTPS for API requests
- Never send tokens in URL parameters
- Only send tokens in the
Authorizationheader
Rotation
- Rotate PATs periodically
- Revoke tokens immediately if compromised
- Use separate tokens for different applications
- Set appropriate expiration times
Principle of Least Privilege
- Request only the scopes your application needs
- Create separate tokens for different use cases
- Use read-only scopes when possible
GitHub Token Compatibility (Deprecated)
For backwards compatibility, some GitHub tokens still work with Modrinth’s API, granting all scopes. This is strongly discouraged for security and reliability.Authentication Errors
401 Unauthorized
Your request lacks valid authentication credentials:- Missing
Authorizationheader - Invalid or expired token
- Revoked token
403 Forbidden
Your token is valid but lacks the required scope:Example: Complete OAuth Implementation
Further Reading
Rate Limits
Learn about request limits and headers
Error Handling
Handle authentication and authorization errors
