Skip to content

Authentication

The ctx.gg API uses OAuth for authentication, supporting GitHub and Discord as identity providers.

  1. Client redirects user to the OAuth provider
  2. User authorizes the ctx.gg application
  3. Provider redirects back with an authorization code
  4. API exchanges the code for an access token
  5. API creates or updates the user record and returns a session token

Redirects to GitHub OAuth authorization page.

Query Parameters:

ParameterTypeDescription
redirectstringURL to redirect after auth (optional)

Handles the GitHub OAuth callback. Creates or updates the user and returns a session.

Redirects to Discord OAuth authorization page.

Handles the Discord OAuth callback.

Returns the currently authenticated user.

Headers:

Authorization: Bearer <session-token>

Response:

{
"id": "user-uuid",
"username": "player1",
"avatar": "https://avatars.githubusercontent.com/...",
"provider": "github",
"createdAt": "2026-01-15T10:00:00Z"
}

Invalidates the current session.

Session tokens are returned as HTTP-only cookies and can also be used as Bearer tokens in the Authorization header. Tokens expire after 30 days of inactivity.