刷新 Token
curl --request POST \
--url https://openapi.bazhuayu.com/token \
--header 'Content-Type: <content-type>' \
--data '
{
"refresh_token": "<string>",
"grant_type": "<string>"
}
'import requests
url = "https://openapi.bazhuayu.com/token"
payload = {
"refresh_token": "<string>",
"grant_type": "<string>"
}
headers = {"Content-Type": "<content-type>"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>'},
body: JSON.stringify({refresh_token: '<string>', grant_type: '<string>'})
};
fetch('https://openapi.bazhuayu.com/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>'},
body: JSON.stringify({refresh_token: '<string>', grant_type: '<string>'})
};
fetch('https://openapi.bazhuayu.com/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://openapi.bazhuayu.com/token"
payload := strings.NewReader("{\n \"refresh_token\": \"<string>\",\n \"grant_type\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://openapi.bazhuayu.com/token")
.header("Content-Type", "<content-type>")
.body("{\n \"refresh_token\": \"<string>\",\n \"grant_type\": \"<string>\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://openapi.bazhuayu.com/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'refresh_token' => '<string>',
'grant_type' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://openapi.bazhuayu.com/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request.body = "{\n \"refresh_token\": \"<string>\",\n \"grant_type\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://openapi.bazhuayu.com/token");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n \"refresh_token\": \"<string>\",\n \"grant_type\": \"<string>\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"refresh_token\": \"<string>\",\n \"grant_type\": \"<string>\"\n}")
val request = Request.Builder()
.url("https://openapi.bazhuayu.com/token")
.post(body)
.addHeader("Content-Type", "<content-type>")
.build()
val response = client.newCall(request).execute()false接口调用凭证
刷新 Token
POST
/
token
刷新 Token
curl --request POST \
--url https://openapi.bazhuayu.com/token \
--header 'Content-Type: <content-type>' \
--data '
{
"refresh_token": "<string>",
"grant_type": "<string>"
}
'import requests
url = "https://openapi.bazhuayu.com/token"
payload = {
"refresh_token": "<string>",
"grant_type": "<string>"
}
headers = {"Content-Type": "<content-type>"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>'},
body: JSON.stringify({refresh_token: '<string>', grant_type: '<string>'})
};
fetch('https://openapi.bazhuayu.com/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>'},
body: JSON.stringify({refresh_token: '<string>', grant_type: '<string>'})
};
fetch('https://openapi.bazhuayu.com/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://openapi.bazhuayu.com/token"
payload := strings.NewReader("{\n \"refresh_token\": \"<string>\",\n \"grant_type\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://openapi.bazhuayu.com/token")
.header("Content-Type", "<content-type>")
.body("{\n \"refresh_token\": \"<string>\",\n \"grant_type\": \"<string>\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://openapi.bazhuayu.com/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'refresh_token' => '<string>',
'grant_type' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://openapi.bazhuayu.com/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request.body = "{\n \"refresh_token\": \"<string>\",\n \"grant_type\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://openapi.bazhuayu.com/token");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n \"refresh_token\": \"<string>\",\n \"grant_type\": \"<string>\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"refresh_token\": \"<string>\",\n \"grant_type\": \"<string>\"\n}")
val request = Request.Builder()
.url("https://openapi.bazhuayu.com/token")
.post(body)
.addHeader("Content-Type", "<content-type>")
.build()
val response = client.newCall(request).execute()false所需套餐: 全部
端点
POST https://openapi.bazhuayu.com/token
描述
token 过期后,允许根据上一次获取 token 时的 refreshToken 刷新获取新的 token。请求头
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
Content-Type | String | 是 | application/json |
{
"Content-Type": "application/json"
}
请求体
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
refresh_token | String | 是 | 刷新 access_token 的凭证 |
grant_type | String | 是 | 固定值填写 refresh_token |
{
"refresh_token": "5p6RhlU0A9AYPLpzfdYG-pyK97uqffrRDG4fgrFv4eo",
"grant_type": "refresh_token"
}
响应
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
data | Object[] | 是 | 响应数据 |
access_token | String | 是 | 访问令牌 |
expires_in | Date | 是 | access_token有效时间(秒)(推荐在有效期间内推荐重复使用),有效期为1天 |
token_type | String | 是 | 令牌类型 |
refresh_token | String | 是 | 刷新access_token的凭证 |
requestId | String | 是 | 请求Id |
{
"data": {
"access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6ImdXS3hWc0F4SHhaMDlDcWh6NkNJb3ciLCJ0eXAiOiJhdCtqd3QifQ.eyJuYmYiOjE2MzY0NjIyNzAsImV4cCI6MTYzNjU0ODY2OSwiaXNzIjoiaHR0cDovL3Rlc3QuaWRlbnRpdHkuYmF6aHVheXUuY29tIiwiY2xpZW50X2lkIjoiT2N0b3B1cyIsInN1YiI6IjllOGJiM2VhLWUwMWQtNGFlZC05ODM3LTVhMWUyODg0NWI5ZSIsImF1dGhfdGltZSI6MTYzNjQ2MjI3MCwiaWRwIjoibG9jYWwiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWR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
"refresh_token": "SSc1Uf56BRfNfSewsZ0FJCHjfqI5FwGW3k2QfiRplN8",
},
"requestId": "0HMD3FSLHJRVO:00000002"
}
错误响应
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
requestId | String | 是 | 请求Id |
error | Object | 是 | 错误信息,参考错误码 |
code | String | 是 | 错误码 |
message | String | 是 | 错误描述 |
{
"error": {
"code": "ServerError",
"message": "Internal Server Error"
},
"requestId": "0HMD469L0I8R0:00000001"
}
⌘I
