OAuth 授权
获取/刷新 token
根据 code 获取 token、根据refresh_token刷新 token。
鉴权方式
OAuth 2.0 是面向第三方应用的用户授权机制。用户通过 OAuth 集成完成授权后,第三方应用可以在授权范围内以用户身份调用 API。
版本
请求地址
Body 参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
grant_type | string | 是 | 根据 code 获取 token 时,grant_type 传入 authorization_code; 根据refresh_token刷新 token时,grant_type 传入 refresh_token。 可选值: "authorization_code""refresh_token" |
code | string | 否 | 授权阶段返回的 code。grant_type 为 authorization_code 时必传。 |
client_id | string | 是 | client_id |
client_secret | string | 是 | client_secret |
redirect_uri | string | 否 | 回调地址。grant_type 为 authorization_code 时必传,且必须与授权阶段一致。 |
refresh_token | string | 否 | 获取 Token 时返回的 refresh_token。grant_type 为 refresh_token 时必传。 |
响应参数
200成功时返回 access_token、refresh_token、expires_in、token_type、scope 等信息| 名称 | 类型 | 描述 |
|---|---|---|
access_token | string | 访问令牌 |
token_type | string | Token 类型 |
expires_in | integer | access_token 有效期,默认 3600 秒(1 小时) |
refresh_token | string | 用于刷新 token 的 refresh_token |
scope | string | 授权范围 |
curl -X POST "https://example.com/v3/oauth/token" \ -H "Content-Type: application/json" \ -d '{ "grant_type": "authorization_code", "code": "returned_code", "client_id": "your_client_id", "client_secret": "your_client_secret", "redirect_uri": "https://example.com/callback" }'{ "access_token": "string", "token_type": "Bearer", "expires_in": 0, "refresh_token": "string", "scope": "data.read data.write"}