---
title: 获取 token
description: POST /api/token.do：获取 token 接口说明，包含路径、方法、参数和返回信息。
slug: api-post-api-token-do
lang: zh
category: 认证 API
category_order: 8
order: 102
api_method: POST
api_path: /api/token.do
api_label: 获取 token
keywords:
  - API
  - 获取 token
  - /api/token.do
---

# 获取 token

| 属性 | 值 |
| --- | --- |
| HTTP 方法 | `POST` |
| 接口路径 | `/api/token.do` |
| 所属分类 | 认证 API |

## 接口说明

接口路径：`/api/token.do`

HTTP 方法：`POST`


**HTTP 方法：** `POST`

#### HTTP Header

该接口使用 Basic Auth 的方式校验 client 的信息。具体做法是在 header 中添加类似于"Authorization: Basic xxxxxxxxx"。其中
"xxxxxxxxx"是通过开发者 id (client_id)和开发者秘钥(client_secret)算出来的，具体算法为 Base64Encode(client_id + ":" + client_secret)
Base64Encode 自行选择工具进行 Base64 编码
#### URL 参数

参数名 Comment(说明)
grant_type（必填） 必须为 authorization_code string
code（必填） 授权码，即回调地址接收到的授权码，授权码的有效期为 5 分钟，用过一次，无论成功
还是失败，授权码都会失效 string
例如：
/api/token.do?grant_type=authorization_code&code=xxx&redirect_uri=http://xxx.xxx.xxx
返回结果
access_token 接口访问标识
refresh_token 用来刷新 access_token，有效时间为 30 天
expires_in access_token 的有效时间，单位为 s

## 调用说明

- 调用前需完成 [获取 token](api-post-api-token-do.md) 或相应免登录认证，并在请求 Header 中携带 `Authorization: Bearer <access_token>`。
- 参数和返回字段如因部署版本存在差异，应以实际私有云 API 文档和联调结果为准。
- 所属分类：认证 API。
