# 访问令牌

用 API ID 与 API Key 换取 OAuth2 Bearer 令牌。
- **前置条件**：`client_id` 是 API ID，`client_secret` 是 API Key。成员必须处于正常状态，且调用方 IP 必须通过 Open API 的 IP 白名单与黑名单校验。
- **副作用**：无——令牌是自签的，服务端不存储任何东西。
- **有效期**：`expires_in` 秒，默认 3600。**没有 refresh token，也没有刷新接口**；需要时重新申请一个。
- **并发**：由于令牌是无状态的，签发新令牌**不会**让旧令牌失效——同一时间可以有多个有效令牌。令牌只会因过期或 API Key 被轮换而失效。
- **重试**：可安全重试。

已记录的业务错误码：`12002`, `35002`, `35005`。 各错误码的含义见 [Error Codes](../Getting%20Started/error-codes.md)。任何接口还可能返回通用错误码。

Endpoint: POST /oauth2/token
Version: 2026-09-05
Security: Authorization

## Header parameters:

  - `Content-Type` (string, required)

## Request fields (application/json):

  - `client_id` (string, required)
    API ID 用于标识成员

  - `client_secret` (string, required)
    API 密钥用于验证客户端 ID。要调用 MoreLogin API，您需要
提供您的 API ID 和 API 密钥以换取访问令牌。
请妥善保管此密钥。

  - `grant_type` (string, required)
    包名 — 仅当未提供 appVersionId 时才需要
    Example: client_credentials

## Response 200:

  - `200` (unknown)
    成功。`data` 是对象，包含字段 `scope`、`access_token`、`token_type`、`expires_in`、`client_metadata`。

## Response 200 fields (application/json):

  - `code` (integer, required)

  - `msg` (string | null, required)

  - `data` (object, required)

  - `data.scope` (string, required)

  - `data.access_token` (string, required)

  - `data.token_type` (string, required)

  - `data.expires_in` (integer, required)

  - `data.client_metadata` (object, required)

  - `data.client_metadata.name` (string, required)

  - `requestId` (string, required)

