Overview
Orquestra uses GitHub OAuth for user authentication. The flow creates or updates a user account in the database and returns a JWT token for subsequent API requests.OAuth Flow
Start OAuth Flow
Initiate the GitHub OAuth login flow.Endpoint
Behavior
Redirects to GitHub’s OAuth authorization page with the following parameters:client_id: GitHub OAuth app client IDredirect_uri:{API_BASE_URL}/auth/github/callbackscope:user:email read:userallow_signup:true
Example
OAuth Callback (Browser)
Handles the OAuth callback from GitHub and redirects to your frontend with a JWT.Endpoint
Query Parameters
Authorization code from GitHub
Behavior
- Exchanges the authorization code for a GitHub access token
- Fetches user information from GitHub API
- Creates or updates the user in the database
- Generates a JWT token (7 day expiration)
- Redirects to
{FRONTEND_URL}/auth/callback?token=<jwt>
Error Handling
On error, redirects to{FRONTEND_URL}/auth/error?message=<error_message>
Frontend Callback Handler Example
OAuth Callback (API)
For programmatic access (CLI tools, scripts), use the POST endpoint to receive the JWT directly as JSON.Endpoint
Request Body
Authorization code from GitHub
Response
JWT authentication token (7 day expiration)
User information
Example
Response Example
Get Current User
Retrieve the authenticated user’s profile information.Endpoint
Authentication
Requires JWT token in theAuthorization header.
Response
Example
cURL
Response Example
Logout
Acknowledge user logout (client should remove the token).Endpoint
Response
Since JWTs are stateless, the server cannot invalidate them. The client must remove the token from storage. Tokens expire after 7 days.
Error Responses
400 Bad Request
- Missing
codeparameter - Invalid authorization code
- Failed to get GitHub access token
401 Unauthorized
- Invalid or expired JWT token (for
/auth/me) - Missing Authorization header
404 Not Found
- User not found (for
/auth/me)
500 Internal Server Error
- GitHub API error
- Database error
Rate Limiting
The/auth/github endpoint is rate-limited to prevent abuse. See Rate Limiting for details.
User Data Management
User Creation
When a user logs in for the first time:- A unique user ID is generated
- GitHub ID, username, email, and avatar are stored
- Timestamps (
created_at,updated_at) are recorded
User Updates
On subsequent logins, the following fields are updated:username(in case the user changed it on GitHub)emailavatar_urlupdated_at
Email Handling
If the GitHub API doesn’t return an email:- Orquestra fetches the user’s email list
- Uses the primary verified email
- Falls back to the first available email
- Uses
<username>@users.noreply.github.comif no email is found
Security Notes
- JWTs are signed with HMAC-SHA256
- Tokens expire after 7 days
- Tokens are validated on every protected endpoint request
- User info is refreshed from GitHub on each login
Related Endpoints
- JWT Authentication - Using JWT tokens in API requests
- API Keys - Alternative authentication for programmatic access