Skip to content

Integration

Wire any world into CGL

Pick a project above and the snippets below fill in its client id, type and namespace. Everything speaks plain HTTP — no SDK is required, and every endpoint is versioned behind the same issuer.

Context

Snippets fill in the credentials of a project you own. Signed out? They show placeholders.

Loading projects…

cgl_your_client_idconfidential client
1 · Send the user to the authorization endpoint
GET https://login.cloudlight.games/oauth/authorize
  ?response_type=code
  &client_id=cgl_your_client_id
  &redirect_uri=https%3A%2F%2Flogin.cloudlight.games%2Fapi%2Fauth%2Fcallback
  &scope=openid%20profile%20email
  &state=RANDOM_STATE
  &code_challenge=PKCE_S256_CHALLENGE   # required for public clients
  &code_challenge_method=S256
2 · Exchange the code at the token endpoint
POST https://login.cloudlight.games/oauth/token
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code
&code=RETURNED_CODE
&redirect_uri=https%3A%2F%2Flogin.cloudlight.games%2Fapi%2Fauth%2Fcallback
&client_id=cgl_your_client_id
&client_secret=YOUR_CLIENT_SECRET

→ { "access_token": "eyJ…", "token_type": "Bearer", "expires_in": 900,
    "refresh_token": "…", "id_token": "eyJ…", "scope": "openid profile email" }
3 · Verify the ID token / read the user
GET https://login.cloudlight.games/.well-known/openid-configuration
GET https://login.cloudlight.games/.well-known/jwks.json

# ID tokens are RS256, issued by https://login.cloudlight.games, audience = your client id.
# Validate iss, aud, exp and the nonce you sent.
GET https://login.cloudlight.games/oauth/userinfo
Authorization: Bearer ACCESS_TOKEN

→ { "sub": "user uuid", "preferred_username": "starweaver",
    "name": "Star Weaver", "email": "…", "email_verified": true }
Minimal PKCE helper (browser or Node 18+)
const random = (n) => crypto.getRandomValues(new Uint8Array(n));
const verifier = btoa(String.fromCharCode(...random(32)))
  .replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");

const digest = await crypto.subtle.digest(
  "SHA-256", new TextEncoder().encode(verifier));
const challenge = btoa(String.fromCharCode(...new Uint8Array(digest)))
  .replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");