跳转至

刷新Access_Token

Access_Token是调用Marketing-API接口的调用凭证,由于Access_Token具有时效性(默认90天),当Access_Token超时后,可以使用Refresh_Token进行刷新,每次刷新都会同时重置二者的有效期,每个自然日的刷新上限是300次。Refresh_Token拥有较长的有效期。

请求地址

https://openapi.aiclk.com/oauth2/token

请求方式

POST

请求参数

传参形式:form-data

字段名 类型 是否必须 描述
client_id string 应用ID,开发者应用的唯一标识
refresh_token string 刷新用token

请求示例

curl -g --location --request POST 'https://openapi.aiclk.com/oauth2/token' \
--form 'client_id=2002721099707' \
--form 'refresh_token=facd1d05a3838ece583722e34d41a98a01c3bc5a79774c5a5071fb20f   db05b7490fd01156b969c013b0f4c831929b6578890544f562fc92d96f4312483a2'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://openapi.aiclk.com/oauth2/token",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('client_id' => '20000027099707','refresh_token'     => 'facd1d05a3838ece583722e34d41a98a01c3bc9774c5a5071fb20fdb05b7490fd01156b96   9c013b0f48aecc831929b6578890544f562fc92d96f4312483a2'),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("client_id", "2000002721099707")
  .addFormDataPart("refresh_token", "facd1d05a3838ece583722e34d41a98a01c3bc5a79   774c5a5071fb20fdb05b7490fd01156b969c013b0f48aecc831929b6578890544f562fc92d96f   4312483a2")
  .build();
Request request = new Request.Builder()
  .url("https://openapi.aiclk.com/oauth2/token")
  .method("POST", body)
  .build();
Response response = client.newCall(request).execute();
import requests

url = "https://openapi.aiclk.com/oauth2/token"

payload = {'client_id': '2000002721099707',
'refresh_token': 'facd1d05a3838ece583722e34d41a98a01c3bc5a79774c5a5071fb20fdb05   b7490fd01156b969c013b0f48aecc831929b6578890544f562fc92d96f4312483a2'}
files = [

]
headers= {}

response = requests.request("POST", url, headers=headers, data = payload, files    = files)

print(response.text.encode('utf8'))

请求返回

{
    "code": 200,
    "data": {
        "access_token": "xxxxxxx",       // 新的access_token
        "expires_in": 7778159,           // 过期时间戳
        "token_type": "OGW_ACCESS_TOKEN" // header token
    },
    "message": "Success",                // message
    "trace_id": "776ac7ef9ccd2cb3"       // trace_id
}