The token endpoint (RFC 6749 §3.2).
const url = 'https://example.com/api/auth/oauth/token';const options = { method: 'POST', headers: { Authorization: 'Basic <credentials>', 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ grant_type: 'authorization_code', code: 'example', redirect_uri: 'example', code_verifier: 'example', refresh_token: 'example', scope: 'example', client_id: 'example', client_secret: 'example' })};
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://example.com/api/auth/oauth/token \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data grant_type=authorization_code \ --data code=example \ --data redirect_uri=example \ --data code_verifier=example \ --data refresh_token=example \ --data scope=example \ --data client_id=example \ --data client_secret=exampleGrants: authorization_code (with the code_verifier and the same redirect_uri), client_credentials and refresh_token. Refresh tokens rotate: presenting one that was rotated already revokes the grant. The client authenticates with HTTP Basic (client_secret_basic) or with client_id and client_secret in the body (client_secret_post), not both. Limited per client IP.
Authorizations
Section titled “Authorizations”- clientBasic
- None
Request Bodyrequired
Section titled “Request Bodyrequired”object
Responses
Section titled “Responses”Tokens.
object
Not for client_credentials.
Example
{ "token_type": "Bearer"}Headers
Section titled “Headers”The request was refused (RFC 6749 §5.2).
An RFC 6749 §5.2 error response.
object
Example
{ "error": "invalid_request"}Headers
Section titled “Headers”Client authentication failed, error invalid_client.
An RFC 6749 §5.2 error response.
object
Example
{ "error": "invalid_request"}Headers
Section titled “Headers”The body is larger than 64 KiB.
An RFC 9457 problem.
object
object
Example generated
{ "type": "example", "title": "example", "status": 1, "detail": "example", "instance": "example", "request_id": "example", "errors": { "additionalProperty": "example" }}This client IP is sending too many requests.
An RFC 9457 problem.
object
object
Example generated
{ "type": "example", "title": "example", "status": 1, "detail": "example", "instance": "example", "request_id": "example", "errors": { "additionalProperty": "example" }}Headers
Section titled “Headers”Seconds to wait.
The service failed; the problem says nothing more.
An RFC 9457 problem.
object
object
Example generated
{ "type": "example", "title": "example", "status": 1, "detail": "example", "instance": "example", "request_id": "example", "errors": { "additionalProperty": "example" }}