# 刷新合作方令牌

> 用有效的 refresh_token 换取新的合作方访问令牌,应在当前令牌到期前刷新。

POST
  https://platform.ikho.cn/developer/api/oauth/partner/refresh-token
  试一试 

  
## 鉴权

  

  
    Authorization
    string
    header
    必填
    
  

  HTTP Basic 认证,值为 Basic base64(client_id:secret)。

  

  

  
    Content-Type
    string
    header
    必填
    默认 application/x-www-form-urlencoded
  

  请求内容类型。

  

  
## 请求体

  

  
    refresh_token
    string
    
    必填
    
  

  合作方令牌签发时返回的 refresh_token。

  

  
## 响应

  

  
    access_token
    string
    
    
    
  

  新的合作方访问令牌。

  

  

  
    refresh_token
    string
    
    
    
  

  新的刷新令牌,用于下一次续期。

  

  

  
    token_type
    string
    
    
    
  

  令牌类型,固定为 bearer。

  

  

  
    expires_in
    integer
    
    
    
  

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

  

  

  cURLPython
  

  

  bash
    
  

  
```
curl -X POST "https://platform.ikho.cn/developer/api/oauth/partner/refresh-token" \
  -u "$CLIENT_ID:$CLIENT_SECRET" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "refresh_token=$REFRESH_TOKEN"
```

  ts
    
  

  
```
import base64, requests

basic = base64.b64encode(fclass="tk-str">"{client_id}:{client_secret}".encode()).decode()

resp = requests.post(
    class="tk-str">"https:class="tk-cmt">//platform.ikho.cn/developer/api/oauth/partner/refresh-token",
    headers={
        class="tk-str">"Authorization": class="tk-str">"Basic " + basic,
        class="tk-str">"Content-Type": class="tk-str">"application/x-www-form-urlencoded",
    },
    data={class="tk-str">"refresh_token": refresh_token},
)
print(resp.json()[class="tk-str">"access_token"])
```

  

  200 响应示例
    
  

  
```
{
  "access_token": "eyJhbGciOiJSUz...",
  "refresh_token": "eyJhbGci...",
  "token_type": "bearer",
  "expires_in": 7200
}
```
