颁发服务帐户访问权限令牌

发布 /api/v1/oauth/token

用服务帐户客户端ID和密钥交换短期不记名令牌。仅支持 grant_type=client_credentials。

body 必需

OAuth 令牌请求。首选使用HTTP基本身份验证作为客户端凭证。

  • client_id 字符串

    ClientID 也可以作为HTTP Basic用户名发送(首选)。

  • client_secret 字符串

    ClientSecret 也可以作为HTTP Basic 密码发送(首选)。

  • grant_type 字符串 必需

    grantType 必须是“client_credentials”。

    值为 client_credentials。

body 必需

OAuth 令牌请求。首选使用HTTP基本身份验证作为客户端凭证。

  • grant_type 字符串 必需

    值为 client_credentials。

  • client_id 字符串
  • client_secret 字符串

响应

  • 200 application/json

    正常

    隐藏响应属性 显示响应属性 对象
    • access_token 字符串
    • expires_in 整型
    • token_type 字符串
  • 400 application/json

    Bad Request

    隐藏响应属性 显示响应属性 对象
    • 错误 字符串
    • error_description 字符串
  • 401 application/json

    Unauthorized

    隐藏响应属性 显示响应属性 对象
    • 错误 字符串
    • error_description 字符串
  • 429 application/json

    请求过多

    隐藏标头属性 显示标头属性
    • 重试后 字符串

      重试前等待的秒数

    隐藏响应属性 显示响应属性 对象
    • 错误 字符串
    • error_description 字符串
  • 500 application/json

    内部服务器错误

    隐藏响应属性 显示响应属性 对象
    • 错误 字符串
    • error_description 字符串
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'
请求示例
{
  "client_id": "string",
  "client_secret": "string",
  "grant_type": "client_credentials"
}
响应示例 (200)
{
  "access_token": "string",
  "expires_in": 42,
  "token_type": "string"
}
响应示例 (400)
{
  "error": "string",
  "error_description": "string"
}
响应示例 (401)
{
  "error": "string",
  "error_description": "string"
}
响应示例 (429)
# Headers
Retry-After: string

# Payload
{
  "error": "string",
  "error_description": "string"
}
响应示例 (500)
{
  "error": "string",
  "error_description": "string"
}