Loopwise Docs
Reference

Token Endpoints

Technical reference for the OAuth 2.0 token, refresh, and revocation endpoints.

Token lifecycle

Token endpoint

POST /api/oauth/token

Exchanges an authorization code for an access token, or refreshes an existing token.

Authorization Code grant

ParameterTypeRequiredDescription
grant_typestringYesMust be authorization_code
codestringYesThe authorization code from the callback
redirect_uristringYesMust match the URI used in the authorization request
client_idstringYesYour application's client ID
code_verifierstringYesThe PKCE code verifier (plain-text, 43-128 chars)
client_secretstringConditionalRequired for confidential clients

Response

{
  "access_token": "eyJhbGciOiJIUzI1NiIs...",
  "token_type": "Bearer",
  "expires_in": 7200,
  "refresh_token": "def456...",
  "scope": "read courses:read students:read",
  "created_at": 1710000000,
  "school_id": 42,
  "school_subdomain": "demo"
}
FieldDescription
access_tokenBearer token for API requests
token_typeAlways Bearer
expires_inToken lifetime in seconds (default: 7200 / 2 hours)
refresh_tokenToken to obtain a new access token
scopeGranted scopes (may be a subset of what was requested)
school_idThe ID of the authorized school
school_subdomainThe subdomain of the authorized school

Refresh Token grant

ParameterTypeRequiredDescription
grant_typestringYesMust be refresh_token
refresh_tokenstringYesA valid refresh token
client_idstringYesYour application's client ID
client_secretstringConditionalRequired for confidential clients

Response

Same format as the authorization code grant response. A new refresh token may be issued — always store the latest one.


Revocation endpoint

POST /api/oauth/revoke

Revokes an access token or refresh token per RFC 7009.

ParameterTypeRequiredDescription
tokenstringYesThe token to revoke
token_type_hintstringNoaccess_token or refresh_token
client_idstringYesYour application's client ID

The endpoint always returns 200 OK, even if the token was already revoked or invalid. This prevents token-guessing attacks.


Introspection endpoint

POST /api/oauth/introspect

Returns metadata about a token per RFC 7662.

ParameterTypeRequiredDescription
tokenstringYesThe token to introspect
client_idstringYesYour application's client ID

Response (active token)

{
  "active": true,
  "scope": "read courses:read",
  "client_id": "abc123",
  "token_type": "Bearer",
  "exp": 1710007200
}

Response (inactive/invalid token)

{
  "active": false
}

Error responses

All token endpoints return errors in the standard OAuth 2.0 format:

{
  "error": "invalid_grant",
  "error_description": "The authorization code has expired or has already been used."
}
ErrorHTTP StatusDescription
invalid_request400Missing or malformed parameter
invalid_client401Client authentication failed
invalid_grant400Code expired, already used, or verifier mismatch
unauthorized_client400Client not authorized for this grant type
unsupported_grant_type400Only authorization_code and refresh_token are supported