System

OAuth2 token (client credentials)

POST/oauth/token
No scope required

Exchange an OAuth2 client's credentials for a short-lived bearer (the client_credentials grant). This endpoint is unauthenticated (it carries no bearer and requires no scope) — it is the auth bootstrap.

A token created as an OAuth2 client (see Settings → API Suite, auth method "OAuth2 client credentials") is issued a client_id (prefixed hlmc_) and a one-time client_secret (prefixed hlms_) instead of a static hlm_ bearer. POST them here to receive an access_token (prefixed hlma_) valid for expires_in seconds (3600 by default). Use that access token as the bearer on the API exactly like a static token:

Authorization: Bearer hlma_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

The optional scope (space-delimited) narrows the access token to a subset of the client's own scopes; omit it to inherit the client's full scope set. Requesting a scope the client does not hold is an invalid_scope error. Errors follow the OAuth2 shape ({ error, error_description }); invalid_client is deliberately opaque and never reveals whether the id or the secret was wrong.

Request body

application/json, required · OAuthTokenRequest

  • grant_typestringRequired#

    Must be client_credentials (the only supported grant).

    One of: client_credentials
  • client_idstringRequired#

    The OAuth2 client id (prefixed hlmc_).

  • client_secretstringRequired#

    The OAuth2 client secret (prefixed hlms_), shown once at creation.

  • scopestring#

    Optional, space-delimited. Narrows the access token to a subset of the client's own scopes; omit to inherit the client's full set.

{
  "grant_type": "client_credentials",
  "client_id": "hlmc_xxxxxxxxxxxxxxxxxxxxxxxx",
  "client_secret": "hlms_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "scope": "investors:read deals:read"
}

Responses

200

OK - a short-lived access token was issued.

{
  "access_token": "hlma_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "investors:read deals:read"
}
400

Bad request. unsupported_grant_type (grant_type is not client_credentials) or invalid_scope (a requested scope exceeds the client's granted scopes).

OAuthError
401

invalid_client — client authentication failed (unknown, revoked or expired client, or wrong secret). Deliberately opaque.

OAuthError

Examples

curl -X POST https://your-org-domain/kong/core/api/v2/oauth/token\
  -H "Authorization: Bearer $HELM_API_KEY"\
  -H "Content-Type: application/json"\
  -d '{
  "grant_type": "client_credentials",
  "client_id": "hlmc_xxxxxxxxxxxxxxxxxxxxxxxx",
  "client_secret": "hlms_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "scope": "investors:read deals:read"
}'