# 获取用户令牌

> 用合作方令牌为你系统里的某位用户签发用户级令牌,交给 Embedded SDK 与文件上传接口使用。

POST
  `https://ikho.cn/developer/api/open/partner/users/access-token`
  [试一试](/docs/embedded/playground/)

  
## 鉴权

  

  
    `Authorization`
    string
    header
    必填
    
  

  `Bearer` 加上你的合作方访问令牌。

  

  

  
    `Content-Type`
    string
    header
    必填
    默认 `application/json`
  

  请求内容类型。

  

  
## 请求体

  

  
    `user_id`
    string
    
    必填
    
  

  你系统里对该用户的稳定标识,长度 6 到 120 个字符。用于把令牌与用户一一对应。

  

  

  
    `expires_in`
    integer
    
    
    默认 `86400`
  

  请求的用户令牌有效期,单位为秒。有效区间为 5 分钟(300)至 30 天(2592000),越界自动钳制到边界值。

  

  
## 响应

  

  
    `access_token`
    string
    
    
    
  

  用户访问令牌。

  

  

  
    `token_type`
    string
    
    
    
  

  令牌类型,固定为 `bearer`。

  

  

  
    `expires_in`
    integer
    
    
    
  

  用户访问令牌有效期,单位为秒。

  

  

  cURLPython
  

  

  bash
    
  

  
```
curl -X POST "https://ikho.cn/developer/api/open/partner/users/access-token" \
  -H "Authorization: Bearer $PARTNER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "clinic_patient_20489",
    "expires_in": 86400
  }'
```

  ts
    
  

  
```
import requests

resp = requests.post(
    "https://ikho.cn/developer/api/open/partner/users/access-token",
    headers={
        "Authorization": "Bearer " + partner_token,
        "Content-Type": "application/json",
    },
    json={"user_id": "clinic_patient_20489", "expires_in": 86400},
)
print(resp.json()["access_token"])
```

  

  200 响应示例
    
  

  
```
{
  "access_token": "eyJhbGci...",
  "token_type": "bearer",
  "expires_in": 86400
}
```
