Auth API reference

Auth API · Consumer-Oauth-M2m

post/{app_slug}/v1/oauth/token

Exchange client_credentials for an access token

Standard OAuth 2.0 client_credentials grant. Returns an app-scoped access token whose `scopes[]` claim is the union of the client's configured scopes. Use for service-to-service calls.

Path parameters

app_slug*string

Slug of the app.

Request body

grant_type*string

OAuth grant type. Only 'client_credentials' is supported.

Example: "client_credentials"

client_id*string

M2M client identifier (m2m_*).

Example: "m2m_a1b2c3d4e5f6..."

client_secret*string

M2M client secret (issued at client creation, never returned again).

Example: "the-secret-returned-by-credentials-create"

Response · 200 An app-scoped M2M access token and its granted scopes.

access_token*string

Access token (RS256 JWT signed with the app JWKS key).

token_type*string

Always `Bearer`.

Example: "Bearer"

expires_in*number

Access-token lifetime in seconds.

Example: 3600

scope*string

Space-separated scopes, RFC 6749.

Example: "user.read user.list"

Example

Request

POST https://api.auth.productcraft.co/{app_slug}/v1/oauth/token
Content-Type: application/json

{
  "grant_type": "client_credentials",
  "client_id": "m2m_a1b2c3d4e5f6...",
  "client_secret": "the-secret-returned-by-credentials-create"
}

Response

{
  "access_token": "string",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "user.read user.list"
}