logo
logo
请输入关键词搜索产品或者文档
中国

中国站

创蓝云智

国际站

Innopaas

API接入规范

更新时间:2026-07-29 13:45:27

OM通用定义

通用请求头

所有的API均需鉴权,即在Header中携带以下信息:

参数名称类型必填描述
Content-TypeString请求体的数据类型。例如 application/jsoncharset=utf-8
AppIDString通过控制台->账号中心->API Key 获取
NonceString随机数(最大长度 128 个字符)。
CurTime
String当前 UTC 时间戳,从 1970 年 1 月 1 日 0 时 0 分 0 秒开始到 现在 的秒数。该时间用于计算 CheckSum 的有效期,请确保与标准时间同步。
CheckSum
String
SHA1(AppSecret + Nonce + CurTime),将该三个参数拼接的字符串进行 SHA1 哈希计算从而生成 16 进制字符(小写)。
- 出于安全性考虑,每个 CheckSum有效期5 分钟,即服务端接收到请求的时间与请求中的 CurTime 相差不能超过 5 分钟,建议每次请求都生成新的 CheckSum,同时 请确认 发起请求的服务器是与标准时间同步的。
- CheckSum 检验失败时会code返回 "120001" 错误码。
X-Custom-TraceId
String

开发者填入的自定义标识,用于与开发者业务服务器中的请求中的上下游请求关联,该由用户自定义和使用

签名生成案例(java代码):

package com.chuanglan.gateway.utils;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class SignUtils {

    private static final long *DEFAULT_EXPIRE_MILLIS *= 5 * 60 * 1000L;

    public static Map<String, String> generateSign(String appSecret) {
        String nonce = UUID.*randomUUID*().toString();
        String curTime = String.*valueOf*(System.*currentTimeMillis*()/1000);
        *validateParams*(appSecret, nonce, curTime);
        String signStr = appSecret + nonce + curTime;
        String sign = DigestUtils.*sha1Hex*(signStr).toUpperCase();
        Map<String, String> map = new HashMap<>();
        map.put("sign", sign);
        map.put("nonce", nonce);
        map.put("curTime", curTime);
        return map;
    }

    public static String generateSign(String appSecret, String nonce, String curTime) {
        *validateParams*(appSecret, nonce, curTime);
        String signStr = appSecret + nonce + curTime;
        return DigestUtils.*sha1Hex*(signStr).toUpperCase();
    }

    public static String generateSign(String appSecret, String nonce, long curTime) {
        return *generateSign*(appSecret, nonce, String.*valueOf*(curTime));
    }

    public static boolean verifySign(String appSecret, String nonce, String curTime, String sign) {
        return *verifySign*(appSecret, nonce, curTime, sign, *DEFAULT_EXPIRE_MILLIS*);
    }

    public static boolean verifySign(String appSecret, String nonce, String curTime, String sign, long expireMillis) {
        if (StringUtils.*isBlank*(sign)) {
            return false;
        }
        try {
            *validateParams*(appSecret, nonce, curTime);
        } catch (IllegalArgumentException e) {
            return false;
        }
        if (!*isCurTimeValid*(curTime, expireMillis)) {
            return false;
        }
        String generateSign = *generateSign*(appSecret, nonce, curTime);
        return generateSign.equalsIgnoreCase(sign);
    }

    private static boolean isCurTimeValid(String curTime, long expireMillis) {
        if (!NumberUtils.*isDigits*(curTime)) {
            return false;
        }
        long curTimeLong;
        try {
            curTimeLong = Long.*parseLong*(curTime);
        } catch (NumberFormatException e) {
            return false;
        }
        long now = System.*currentTimeMillis*();
        return (curTimeLong >= now - expireMillis) && (curTimeLong <= now + expireMillis);
    }

    private static void validateParams(String appSecret, String nonce, String curTime) {
        if (StringUtils.*isBlank*(appSecret)) {
            throw new IllegalArgumentException("AppSecret不能为空");
        }
        if (StringUtils.*isBlank*(nonce)) {
            throw new IllegalArgumentException("Nonce不能为空");
        }
        if (StringUtils.*isBlank*(curTime)) {
            throw new IllegalArgumentException("CurTime不能为空");
        }
    }

    public static void main(String[] args) {
        String appId     = "your_app_id";
        String appSecret = "your_app_secret";

        Map<String, String> result = *generateSign*(appSecret);

        System.*out*.println("AppID:    " + appId);
        System.*out*.println("Nonce:    " + result.get("nonce"));
        System.*out*.println("CurTime:  " + result.get("curTime"));
        System.*out*.println("CheckSum: " + result.get("sign"));
    }
}

通用code码

状态码 (code)描述 (msg)解决方案 (solution)
000000success
120001signature verification failed验签失败
120401invalid tokentoken过期,请联系客服人员
120301request header is missing AppID or incorrectAppID有误,请联系客服人员
120302missing parameters in message header请检查请求头参数是否缺失
120403insufficient allocated permissions权限不足,请联系客服人员
120504signature expired签名失效,请核对签名有效时间5分钟
190001request failed请求失败,请联系客服人员
190004invalid parameter参数错误
190403forbidden添加IP白名单
24小时热线 400-9669-253