background image

OAuth

Trade an authorization code or refresh token for tokens, and revoke refresh tokens. See Getting Started for the whole sign-in flow.

Background and examples: Getting Started

Get tokens

POST /v1/oauth/token

OAuth 2.0 token endpoint. Exchanges authorization codes or refresh tokens for access tokens. Supports two grant types: authorization_code and refresh_token.

No token needed.

Request body application/x-www-form-urlencoded

grant_type string required

authorization_code to trade a code from the sign-in page, or refresh_token to refresh.

client_id uuid required

The OAuth client's id.

client_secret string required

The OAuth client's secret. Keep it on your server.

redirect_uri string

With authorization_code: the redirect URL used to sign in, exactly as registered.

code string

With authorization_code: the code the sign-in page sent to your redirect URL.

refresh_token string

With refresh_token: the refresh token to trade for a new pair.

Responses

  • 200 Returns the access token, refresh token, and expiration time.
  • 400 If the grant type is invalid, authorization code is invalid, redirect URI doesn't exactly match a registered one, or other validation errors occur.
  • 401 If the client secret doesn't match the client ID.

Request

curl -X POST 'https://api.stellards.io/v1/oauth/token' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'grant_type=authorization_code&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&redirect_uri=REDIRECT_URI&code=AUTHORIZATION_CODE'

Response 200

{
  "access_token": "eyJhbGciOi...",
  "refresh_token": "eyJhbGciOi...",
  "expires_in": 1770,
  "token_type": "Bearer"
}

Revoke a refresh token

POST /v1/oauth/revoke

Revokes an OAuth refresh token, invalidating it and preventing it from being used to obtain new access tokens.

No token needed.

Request body application/json

The revoke request containing client credentials and the refresh token to revoke.

  • ClientId: The GUID of the OAuth client.
  • ClientSecret: The client secret for authentication.
  • Refresh: The refresh token hash to revoke.
refresh_token string required

The refresh token to revoke.

client_id uuid required

The OAuth client's id.

client_secret string required

The OAuth client's secret.

Responses

  • 200 The refresh token was successfully revoked.
  • 400 If the client ID is not found, refresh token is not found, or validation fails.
  • 401 If the client secret doesn't match the client ID.

Request

curl -X POST 'https://api.stellards.io/v1/oauth/revoke' \
  -H 'Content-Type: application/json' \
  -d '{
    "client_id": "CLIENT_ID",
    "client_secret": "CLIENT_SECRET",
    "refresh_token": "REFRESH_TOKEN"
  }'