Exchange M2M client credentials for an access token (RFC 6749 section 4.4).
const url = 'https://api.siteqwality.com/oauth2/token';const options = { method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: new URLSearchParams('')};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.siteqwality.com/oauth2/token \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data ''Accepts a form-encoded body, HTTP Basic client authentication, or a JSON body. Returns a bare RFC 6749 token response with no envelope.
Request Body required
Section titled “Request Body required ”Form-encoded: grant_type=client_credentials&client_id=…&client_secret=…[&scope=read:monitors write:incidents]
Responses
Section titled “ Responses ”Access token
RFC 6749 section 5.1 successful access-token response.
object
The bearer token to send as Authorization: Bearer <token>.
Always “Bearer” (RFC 6750 casing).
Lifetime in seconds, passed through from the issuer.
Space-delimited granted scopes. Absent when the token carries none.
Example generated
{ "access_token": "example", "token_type": "example", "expires_in": 1, "scope": "example"}Invalid_request, unsupported_grant_type, or invalid_scope
RFC 6749 section 5.2 error response.
object
One of the RFC 6749 error codes: invalid_request, invalid_client,
invalid_scope, unsupported_grant_type, temporarily_unavailable.
Human-readable detail. Never distinguishes “unknown client” from
“wrong secret”: both are invalid_client with the same description.
Example generated
{ "error": "example", "error_description": "example"}Invalid_client
RFC 6749 section 5.2 error response.
object
One of the RFC 6749 error codes: invalid_request, invalid_client,
invalid_scope, unsupported_grant_type, temporarily_unavailable.
Human-readable detail. Never distinguishes “unknown client” from
“wrong secret”: both are invalid_client with the same description.
Example generated
{ "error": "example", "error_description": "example"}Temporarily_unavailable (rate limited)
RFC 6749 section 5.2 error response.
object
One of the RFC 6749 error codes: invalid_request, invalid_client,
invalid_scope, unsupported_grant_type, temporarily_unavailable.
Human-readable detail. Never distinguishes “unknown client” from
“wrong secret”: both are invalid_client with the same description.
Example generated
{ "error": "example", "error_description": "example"}Temporarily_unavailable (issuer unreachable)
RFC 6749 section 5.2 error response.
object
One of the RFC 6749 error codes: invalid_request, invalid_client,
invalid_scope, unsupported_grant_type, temporarily_unavailable.
Human-readable detail. Never distinguishes “unknown client” from
“wrong secret”: both are invalid_client with the same description.
Example generated
{ "error": "example", "error_description": "example"}