Issue a service account access token

POST /api/v1/oauth/token

Exchanges a service account client ID and secret for a short-lived bearer token. Only grant_type=client_credentials is supported.

Body Required

OAuth token request. Prefer HTTP Basic auth for client credentials.

  • client_id string

    ClientID may also be sent as the HTTP Basic username (preferred).

  • client_secret string

    ClientSecret may also be sent as the HTTP Basic password (preferred).

  • grant_type string Required

    GrantType must be "client_credentials".

    Value is client_credentials.

Body Required

OAuth token request. Prefer HTTP Basic auth for client credentials.

  • grant_type string Required

    Value is client_credentials.

  • client_id string
  • client_secret string

Responses

  • 200 application/json

    OK

    Hide response attributes Show response attributes object
    • access_token string
    • expires_in integer
    • token_type string
  • 400 application/json

    Bad Request

    Hide response attributes Show response attributes object
    • error string
    • error_description string
  • 401 application/json

    Unauthorized

    Hide response attributes Show response attributes object
    • error string
    • error_description string
  • 429 application/json

    Too Many Requests

    Hide headers attribute Show headers attribute
    • Retry-After string

      Seconds to wait before retrying

    Hide response attributes Show response attributes object
    • error string
    • error_description string
  • 500 application/json

    Internal Server Error

    Hide response attributes Show response attributes object
    • error string
    • error_description string
POST /api/v1/oauth/token
curl \
 --request POST 'https://agentengine.mongodb.com/api/v1/oauth/token' \
 --header "Authorization: $API_KEY" \
 --header "Content-Type: application/json" \
 --data '{
  "client_id": "string",
  "client_secret": "string",
  "grant_type": "client_credentials"
}'
curl \
 --request POST 'https://agentengine.mongodb.com/api/v1/oauth/token' \
 --header "Authorization: $API_KEY" \
 --header "Content-Type: application/x-www-form-urlencoded" \
 --data 'grant_type=client_credentials&client_id=string&client_secret=string'
Request examples
{
  "client_id": "string",
  "client_secret": "string",
  "grant_type": "client_credentials"
}
Response examples (200)
{
  "access_token": "string",
  "expires_in": 42,
  "token_type": "string"
}
Response examples (400)
{
  "error": "string",
  "error_description": "string"
}
Response examples (401)
{
  "error": "string",
  "error_description": "string"
}
Response examples (429)
# Headers
Retry-After: string

# Payload
{
  "error": "string",
  "error_description": "string"
}
Response examples (500)
{
  "error": "string",
  "error_description": "string"
}