Get TOKEN

Exchange token through code.

Request Method: POST

Request Path: /v2/biz/code2token

Request Body: application/json

Request Body
{
  "appId": "appId",
  "code": "String"
}

code Generate

Use Data Encryption to generate code.

Generate code params:

{ "appId": "Merchants appId", "appSecret": "Merchants appSecret", }

code Generate Example:

Java
PHP
// 1. Build parameter
HashMap<String, Object> data = new HashMap<>(3);
data.put("appId", "4D19348CCFB71BE1ACC457C02259B45B");
data.put("appSecret", "91715E74D4CE8555C84E96D59EB34B50");
// 2. Add timestamp
data.put("timestamp", System.currentTimeMillis());
// 3. Serialization parameter
String json = JSONUtil.toJsonStr(data);
// 4. Use public key encryption to get the encrypted string
RSA rsa = new RSA(null, "PublicKeyStr");
byte[] encrypt = rsa.encrypt(json, KeyType.PublicKey);
String code = Base64.encode(encrypt);

Reponse Data

Reponse example
{
    "code": 200,
    "message": "Success",
    "data": {
        "AccessToken": {
            "value": "abbf2f919b9cf7901e529882e4e5df92",
            "expire": 1718611794854
        },
        "RefreshToken": {
            "value": "ccd5a09a4001f3600f6523f5d0e18e2e",
            "expire": 1718618994876
        }
    }
}