颁发服务账户访问令牌

发布 /api/v1/oauth/token

交换服务帐户客户端 ID 和密钥,以获取有效期短的 Bearer token。只支持 grant_type=client_credentials。

body 必需

OAuth token 请求。优先使用 HTTP Basic 认证来验证客户端凭证。

  • client_id 字符串

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

  • client_secret 字符串

    ClientSecret 也可以作为 HTTP Basic 密码发送(推荐)。

  • grant_type 字符串 必需

    授权类型必须是 "client_credentials"。

    值为 client_credentials。

body 必需

OAuth token 请求。优先使用 HTTP Basic 认证来验证客户端凭证。

  • 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

    请求过多

    隐藏头部属性 显示标头属性
    • Retry-After 字符串

      再次尝试前等待时间(秒)

    隐藏响应属性 显示响应属性 对象
    • 错误 字符串
    • 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"
}