跳转到主要内容
1签 (OneSign)

查询签名任务对应的准确产物

本页内容

查询一次签名任务使用的原包版本和实际生成的签名包版本。

适用场景

需要下载某次签名结果,尤其是同一应用存在多次签名时使用。

开始前

请先在开发者中心完成 API 接入配置,并为目标应用授予本次操作所需的权限。尚未完成首次调用时,请先阅读快速开始。

  • 先取得本次签名任务 ID。此接口按任务关联版本,不按历史版本的排列顺序猜测结果。
所需权限
须同时授予 enterprise:ReadJobs 和 enterprise:ReadVersions;仅当前账号自己的 enterprise 任务
认证方式
长期 AccessKey(AKP)、获准读取该应用的临时凭据(AKT),或用户同意范围内的 OAuth Bearer

权限、应用范围和来源 IP 均需符合接入配置。详细说明见访问权限。

调用步骤

  1. 使用此前保存的签名任务 ID。
  2. 读取 result_state 和 signed_version。
  3. 结果可用时,使用 signed_version.id 申请签名包下载凭证。

以该任务返回的结果为准;版本列表中最新的一项可能属于其他任务。

请求方式

GET /api/v1/apps/{app_id}/jobs/{job_id}/result
操作标识
getJobResult
请求域名
https://www.onesignios.com
频率限制
账号与 API 应用的额度同时生效。达到限额时按 Retry-After 等待。

请求参数

字段必填说明
app_id 是

业务应用的完整 ID,来自列出应用或预留新应用的响应。

类型:string · 位置:Path

查看取值约束
  • 格式 ^A[a-f0-9]{32}$

示例:A11111111111111111111111111111111

job_id 是

创建签名任务返回的签名任务 ID,必须属于路径中的应用。

类型:string · 位置:Path

查看取值约束
  • 格式 ^J[a-f0-9]{32}$

示例:Jcccccccccccccccccccccccccccccccc

AccessKey 认证请求头

下表适用于 AccessKey 调用,由服务端 SDK 自动生成。使用长期或临时凭据自行实现 HTTP 调用时,请按照请求签名说明处理。

字段必填说明
Authorization 是

AccessKey 调用的认证签名,格式为 CS1-HMAC-SHA256 Credential=密钥ID,Signature=签名。使用 SDK 时自动生成。

类型:string · 位置:Header

X-Api-Date 是

UTC 时间,格式 YYYY-MM-DDTHH:mm:ssZ。与服务器的时间偏差最多 300 秒。

类型:string · 位置:Header

查看取值约束
  • 数据格式 date-time
X-Api-Nonce 是

每次请求生成 16 个随机字节,转为 32 位小写十六进制。重试时重新生成。

类型:string · 位置:Header

查看取值约束
  • 格式 ^[a-f0-9]{32}$
X-Api-Content-Sha256 是

实际发送的正文原始字节的 SHA-256 小写十六进制。GET 计算空字节串。

类型:string · 位置:Header

查看取值约束
  • 格式 ^[a-f0-9]{64}$
X-Api-Environment 是

生产环境传 production。

类型:string · 位置:Header

查看取值约束
  • 固定值 production
X-Api-Security-Token 否

仅使用 AKT 时必传。令牌放入此头,令牌摘要追加到签名串。

类型:string · 位置:Header

查看取值约束
  • 格式 ^CST_[A-Za-z0-9_-]{43}$

使用获准的 OAuth 调用时,发送 Authorization: Bearer <access_token>,不发送 AccessKey 的日期、nonce、正文摘要、环境或安全令牌头。POST 仍需 JSON 和幂等键,具体范围以本接口的认证要求为准。查看认证方式对照。

请求体

GET 请求不发送正文。签名中的正文摘要取零字节内容的 SHA-256。

成功响应

HTTP 200 返回 JSON。请记录 request_id,排查问题时可提供此值。查看成功、失败与异步结果的区别。

如何判断结果

result_state=available 且 signed_version 非空时,使用其中的 id 获取该任务签名包。pending 继续等待;not_produced 表示未成功生成。

not_recorded 表示旧任务缺少可信关联,removed 表示产物已清理。这两种情况都不能改用应用最新版本冒充该任务结果。

返回字段

字段按对象层级列出,[] 表示数组元素。“必返”指该对象出现时字段是否必须存在,值仍可能允许为 null;具体类型见展开说明。

字段必返说明
request_id 是

平台生成的请求标识。排查问题时请提供此值。

类型:string

查看取值约束
  • 格式 ^[a-f0-9]{32}$

示例:00000000000000000000000000000000

data 是

以任务不可变关联查询的结果快照,不依赖版本列表顺序。

类型:object

data.app_id 是

任务所属的完整应用 ID。

类型:string

查看取值约束

当前账号拥有且获授权的企业签名应用完整 A 标识。

  • 格式 ^A[a-f0-9]{32}$

示例:A11111111111111111111111111111111

data.job_id 是

本次查询的完整签名任务 ID。

类型:string

查看取值约束

本次查询的准确签名任务 J 标识。

  • 格式 ^J[a-f0-9]{32}$

示例:Jcccccccccccccccccccccccccccccccc

data.status 是

此签名任务的状态。任务成功后还需检查 result_state 和 signed_version。

类型:string

查看取值约束

任务状态。succeeded 表示发布完成,仍须检查 result_state。

  • 可选值 preparing / ready / leased / running / verifying / publishing / succeeded / failed / cancelled / superseded
  • preparing — 准备任务
  • ready — 等待分配执行
  • leased — 节点已领取
  • running — 正在签名
  • verifying — 校验签名结果
  • publishing — 发布签名产物
  • succeeded — 执行成功
  • failed — 执行失败
  • cancelled — 已取消
  • superseded — 已被后续任务替代

示例:succeeded

data.terminal 是

是否为终态:succeeded、failed、cancelled、superseded。

类型:boolean

查看示例

示例:true

data.result_state 是

此任务产物的可用状态。available 时读取 signed_version;其他状态按接口的结果判断说明处理。

类型:string

查看取值约束

pending 正在执行;available 可取准确签名 V;not_produced 任务未成功;not_recorded 旧任务无可信关联;removed 产物版本已清理。

  • 可选值 pending / available / not_produced / not_recorded / removed

示例:available

data.source_version 是

本次签名实际使用的原包版本。

类型:object | null

查看取值约束

该 J 实际输入的原包版本。若已清理则为 null,不是签名包。

data.source_version.id 是

该条记录的公开标识。调用后续接口时请完整保留,包括前缀。

类型:string

查看取值约束
  • 格式 ^V[a-f0-9]{32}$

示例:Vaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

data.source_version.app_id 是

业务应用的完整 ID,来自列出应用或预留新应用的响应。

类型:string

查看取值约束
  • 格式 ^A[a-f0-9]{32}$

示例:A11111111111111111111111111111111

data.source_version.bundle_id 是

IPA 的 Bundle ID 或 APK 的包名,须与对应安装包一致。

类型:string

查看示例

示例:com.fixture.application

data.source_version.platform 是

安装包平台。ipa 对应 iOS,apk 对应 Android。

类型:string

查看取值约束
  • 可选值 ipa / apk
  • ipa — iOS 安装包
  • apk — Android 安装包

示例:ipa

data.source_version.version 是

安装包对用户展示的版本号。

类型:string

查看示例

示例:1.2

data.source_version.build 是

安装包的内部构建版本。

类型:string

查看示例

示例:12

data.source_version.size_bytes 是

文件大小,单位为字节。

类型:integer

查看示例

示例:123456

data.source_version.package_type 是

original 为原始上传包,signed 为签名后的产物。

类型:string

查看取值约束
  • 可选值 original / signed
  • original — 原始上传包
  • signed — 签名后的安装包

示例:original

data.source_version.is_current 是

该类型安装包的当前发布标记;原包与签名包可各自为当前版本

类型:boolean

查看示例

示例:true

data.source_version.created_at 是

Unix 秒;无法解析的旧时间为 0

类型:integer

查看示例

示例:1793937600

data.signed_version 是

明确关联到本次任务的签名产物版本;结果尚不可用时按空值处理。

类型:object | null

查看取值约束

仅 available 时返回准确的签名版本;其他状态为 null。id 用于 DownloadSigned 票据;不要求 is_current=true。

data.signed_version.id 是

该条记录的公开标识。调用后续接口时请完整保留,包括前缀。

类型:string

查看取值约束
  • 格式 ^V[a-f0-9]{32}$

示例:Vbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

data.signed_version.app_id 是

业务应用的完整 ID,来自列出应用或预留新应用的响应。

类型:string

查看取值约束
  • 格式 ^A[a-f0-9]{32}$

示例:A11111111111111111111111111111111

data.signed_version.bundle_id 是

IPA 的 Bundle ID 或 APK 的包名,须与对应安装包一致。

类型:string

查看示例

示例:com.fixture.application

data.signed_version.platform 是

安装包平台。ipa 对应 iOS,apk 对应 Android。

类型:string

查看取值约束
  • 可选值 ipa / apk
  • ipa — iOS 安装包
  • apk — Android 安装包

示例:ipa

data.signed_version.version 是

安装包对用户展示的版本号。

类型:string

查看示例

示例:1.2

data.signed_version.build 是

安装包的内部构建版本。

类型:string

查看示例

示例:12

data.signed_version.size_bytes 是

文件大小,单位为字节。

类型:integer

查看示例

示例:123456

data.signed_version.package_type 是

original 为原始上传包,signed 为签名后的产物。

类型:string

查看取值约束
  • 可选值 original / signed
  • original — 原始上传包
  • signed — 签名后的安装包

示例:signed

data.signed_version.is_current 是

该类型安装包的当前发布标记;原包与签名包可各自为当前版本

类型:boolean

查看示例

示例:false

data.signed_version.created_at 是

Unix 秒;无法解析的旧时间为 0

类型:integer

查看示例

示例:1793937600

data.published_at 是

可信关联记录中的发布时间(Unix 秒);尚未发布或旧记录缺失时为 null。

类型:integer | null

查看取值约束
  • integer (最小值 1)

示例:1794592800

调用示例

请把示例中的应用 ID、资源 ID和业务数据替换为自己账号的真实返回值,再选择一种语言运行。安装、文件放置和 CLOUDSIGN_BASE_URL 等配置见SDK 使用说明。

下载示例依赖

Python 标准库示例使用 cloudsign_request.py;使用 SDK 时仅需准备所选语言。长期 Secret 保存在服务端,浏览器和移动端使用OAuth 授权。

准确签名产物
HTTP 请求
GET /api/v1/apps/A11111111111111111111111111111111/jobs/Jcccccccccccccccccccccccccccccccc/result HTTP/1.1
Host: www.onesignios.com
Authorization: CS1-HMAC-SHA256 Credential=<AccessKey ID>,Signature=<签名>
X-Api-Date: <当前 UTC 时间>
X-Api-Nonce: <新生成的 32 位十六进制值>
X-Api-Content-Sha256: <正文摘要>
X-Api-Environment: production
Python 标准库调用
Python
from cloudsign_request import request

result = request(
    'GET',
    '/api/v1/apps/A11111111111111111111111111111111/jobs/Jcccccccccccccccccccccccccccccccc/result',
)
print(result["request_id"])
Python SDK 调用
Python SDK
import os
from cloudsign import Client

client = Client(
    "https://www.onesignios.com",
    os.environ["CLOUDSIGN_ACCESS_KEY_ID"],
    os.environ["CLOUDSIGN_ACCESS_KEY_SECRET"],
    os.environ.get("CLOUDSIGN_SECURITY_TOKEN", ""),
)

result = client.get_job_result(
    app='A11111111111111111111111111111111',
    job='Jcccccccccccccccccccccccccccccccc',
)
print(result["request_id"])
PHP SDK 调用
PHP SDK
<?php
declare(strict_types=1);

// Extract the PHP SDK source ZIP beside this file. Keep credentials on your server.
require_once __DIR__ . '/cloudsign-sdk/php/Client.php';
$requiredEnv = static function (string $name): string {
    $value = getenv($name);
    if ($value === false || $value === '') { throw new RuntimeException('Missing environment variable'); }
    return $value;
};
try {
    $client = new \Cloudsign\Sdk\Client(
        $requiredEnv('CLOUDSIGN_BASE_URL'),
        $requiredEnv('CLOUDSIGN_ACCESS_KEY_ID'),
        $requiredEnv('CLOUDSIGN_ACCESS_KEY_SECRET'),
        getenv('CLOUDSIGN_SECURITY_TOKEN') ?: '',
    );
    $result = $client->getJobResult(
        'A11111111111111111111111111111111',
        'Jcccccccccccccccccccccccccccccccc'
    );
    echo $result['request_id'], PHP_EOL;
} catch (\Cloudsign\Sdk\ApiError $error) {
    fwrite(STDERR, 'HTTP ' . $error->status . ' ' . $error->apiCode . '; RequestId: ' . $error->requestId . PHP_EOL);
    exit(1);
} catch (Throwable $error) {
    fwrite(STDERR, "Check SDK path, runtime and environment variables.\n");
    exit(1);
}
Node.js SDK 调用
Node.js SDK
// Node.js 20+ on a trusted server. Do not bundle this SDK in browsers or Vue.
import { ApiError, Client } from './cloudsign-sdk/node/client.mjs';

const requiredEnv = name => {
    const value = process.env[name];
    if (!value) throw new Error('Missing environment variable');
    return value;
};
try {
    const client = new Client(
        requiredEnv('CLOUDSIGN_BASE_URL'),
        requiredEnv('CLOUDSIGN_ACCESS_KEY_ID'),
        requiredEnv('CLOUDSIGN_ACCESS_KEY_SECRET'),
        process.env.CLOUDSIGN_SECURITY_TOKEN || '',
    );
    const result = await client.getJobResult(
        "A11111111111111111111111111111111",
        "Jcccccccccccccccccccccccccccccccc"
    );
    console.log(result.request_id);
} catch (error) {
    if (error instanceof ApiError) console.error(`HTTP ${error.status} ${error.code}; RequestId: ${error.requestId}`);
    else console.error('Check SDK path, runtime and environment variables.');
    process.exitCode = 1;
}
Go SDK 调用
Go SDK
// Go 1.22+, trusted server. Extract the Go SDK ZIP beside example.go.
package main

import (
    "context"
    "errors"
    "fmt"
    "os"
    "time"

    cloudsign "cloudsign/sdk"
)

func main() {
    fail := func(err error) {
        var api *cloudsign.APIError
        if errors.As(err, &api) {
            fmt.Fprintf(os.Stderr, "HTTP %d %s; RequestId: %s\n", api.Status, api.Code, api.RequestID)
        } else {
            fmt.Fprintln(os.Stderr, "Check SDK path, runtime and environment variables.")
        }
        os.Exit(1)
    }
    client, err := cloudsign.New(
        os.Getenv("CLOUDSIGN_BASE_URL"),
        os.Getenv("CLOUDSIGN_ACCESS_KEY_ID"),
        os.Getenv("CLOUDSIGN_ACCESS_KEY_SECRET"),
        os.Getenv("CLOUDSIGN_SECURITY_TOKEN"),
    )
    if err != nil { fail(err); return }
    ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
    defer cancel()
    result, err := client.GetJobResult(
		ctx,
		"A11111111111111111111111111111111",
		"Jcccccccccccccccccccccccccccccccc",
	)
    if err != nil { fail(err); return }
    fmt.Println(result.RequestID)
}
Java SDK 调用
Java SDK
// Java 17+, server-side. Extract the Java SDK ZIP beside Example.java.
import com.cloudsign.openapi.Client;
import java.util.*;

public class Example {
    private static String env(String name) {
        String value = System.getenv(name);
        if (value == null || value.isEmpty()) throw new IllegalArgumentException("Missing environment variable");
        return value;
    }
    private static Map<String,Object> object(Object... pairs) {
        var result = new LinkedHashMap<String,Object>();
        for (int i = 0; i < pairs.length; i += 2) result.put((String)pairs[i], pairs[i+1]);
        return result;
    }
    public static void main(String[] args) {
        try {
            var client = new Client(
                env("CLOUDSIGN_BASE_URL"),
                env("CLOUDSIGN_ACCESS_KEY_ID"),
                env("CLOUDSIGN_ACCESS_KEY_SECRET"),
                System.getenv().getOrDefault("CLOUDSIGN_SECURITY_TOKEN", "")
            );
            var result = client.getJobResult(
                "A11111111111111111111111111111111",
                "Jcccccccccccccccccccccccccccccccc"
            );
            System.out.println(result.requestId());
        } catch (Client.ApiException error) {
            System.err.printf("HTTP %d %s; RequestId: %s%n", error.status, error.code, error.requestId);
            System.exit(1);
        } catch (Exception error) {
            if (error instanceof InterruptedException) Thread.currentThread().interrupt();
            System.err.println("Check SDK path, runtime and environment variables.");
            System.exit(1);
        }
    }
}
Rust SDK 调用
Rust SDK
// Rust 1.88+, trusted server. Save as cloudsign-sdk/rust/examples/example.rs.
use cloudsign_openapi::{Client, Credentials, GetJobResult};
use serde_json::json;
use std::{env, error::Error};

async fn run() -> Result<(), Box<dyn Error>> {
    let origin = env::var("CLOUDSIGN_BASE_URL")?;
    let credentials = Credentials::new(
        env::var("CLOUDSIGN_ACCESS_KEY_ID")?,
        env::var("CLOUDSIGN_ACCESS_KEY_SECRET")?,
        env::var("CLOUDSIGN_SECURITY_TOKEN").ok().filter(|v| !v.is_empty()),
        None,
    )?;
    let client = Client::new(&origin, credentials)?;
    let input: GetJobResult = serde_json::from_value(json!({
        "app_id": "A11111111111111111111111111111111",
        "job_id": "Jcccccccccccccccccccccccccccccccc"
    }))?;
    let result = client.get_job_result(&input).await?;
    println!("{}", result.request_id);
    Ok(())
}

#[tokio::main]
async fn main() {
    if let Err(error) = run().await {
        if let Some(api) = error.downcast_ref::<cloudsign_openapi::Error>() {
            eprintln!("HTTP {} {}; RequestId: {}", api.status, api.code, api.request_id.as_deref().unwrap_or(""));
        } else {
            eprintln!("Check SDK path, runtime, environment variables and business input.");
        }
        std::process::exit(1);
    }
}
C SDK 调用

请求对象和响应对象的使用方式见C SDK 请求与响应。

C SDK
/* C11, trusted server. Save as example.c in the source ZIP root. */
#include <cloudsign/openapi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int copy_env(char *out, size_t capacity, const char *name, int required) {
    const char *value = getenv(name);
    if (!value || !*value) return !required;
    size_t length = strlen(value);
    if (length >= capacity) return 0;
    memcpy(out, value, length + 1);
    return 1;
}

int main(void) {
    cloudsign_credentials credentials = {0};
    cloudsign_client *client = NULL;
    cloudsign_result *result = NULL;
    cloudsign_decoded_response *decoded = NULL;
    cloudsign_built_request *built = NULL;
    cloudsign_status status = CLOUDSIGN_INVALID_CONFIGURATION;
    int initialized = 0, exit_code = 1;
    const char *origin = getenv("CLOUDSIGN_BASE_URL");
    if (!origin || !copy_env(credentials.access_key_id, sizeof(credentials.access_key_id), "CLOUDSIGN_ACCESS_KEY_ID", 1)
        || !copy_env(credentials.access_key_secret, sizeof(credentials.access_key_secret), "CLOUDSIGN_ACCESS_KEY_SECRET", 1)
        || !copy_env(credentials.security_token, sizeof(credentials.security_token), "CLOUDSIGN_SECURITY_TOKEN", 0)) goto done;
    status = cloudsign_global_init();
    if (status != CLOUDSIGN_OK) goto done;
    initialized = 1;
    cloudsign_options options = {.origin = origin, .credentials = &credentials, .timeout_ms = 15000};
    status = cloudsign_client_create(&options, &client);
    cloudsign_credentials_clear(&credentials);
    if (status != CLOUDSIGN_OK) goto done;
    const cloudsign_input_get_job_result input = {.presence_app_id = CLOUDSIGN_FIELD_VALUE, .app_id = "A11111111111111111111111111111111", .presence_job_id = CLOUDSIGN_FIELD_VALUE, .job_id = "Jcccccccccccccccccccccccccccccccc"};
    status = cloudsign_build_get_job_result(&input, &built);
    if (status != CLOUDSIGN_OK) goto done;
    status = cloudsign_send_built_request(client, built, &result);
    if (status == CLOUDSIGN_OK) {
        status = cloudsign_decode_get_job_result(result, &decoded);
        if (status != CLOUDSIGN_OK) goto done;
        const cloudsign_model_job_result *data = cloudsign_response_get_job_result(decoded);
        if (!data) { status = CLOUDSIGN_INVALID_RESPONSE; goto done; }
        /* Read typed fields here; NULL/absent is distinct from zero/false. */
        (void)data;
        puts(cloudsign_decoded_request_id(decoded));
        exit_code = 0;
    }
done:
    if (exit_code) {
        if (status == CLOUDSIGN_API_ERROR) fprintf(stderr, "HTTP %ld %s; RequestId: %s\n", cloudsign_result_http_status(result), cloudsign_result_error_code(result), cloudsign_result_request_id(result));
        else fputs("Check SDK path, runtime, environment variables and business input.\n", stderr);
    }
    cloudsign_result_free(result);
    cloudsign_decoded_free(decoded);
    cloudsign_built_request_free(built);
    cloudsign_client_free(client);
    if (initialized) cloudsign_global_cleanup();
    cloudsign_credentials_clear(&credentials);
    return exit_code;
}
JSON 响应
{
    "request_id": "00000000000000000000000000000000",
    "data": {
        "app_id": "A11111111111111111111111111111111",
        "job_id": "Jcccccccccccccccccccccccccccccccc",
        "status": "succeeded",
        "terminal": true,
        "result_state": "available",
        "source_version": {
            "id": "Vaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            "app_id": "A11111111111111111111111111111111",
            "bundle_id": "com.fixture.application",
            "platform": "ipa",
            "version": "1.2",
            "build": "12",
            "size_bytes": 123456,
            "package_type": "original",
            "is_current": true,
            "created_at": 1793937600
        },
        "signed_version": {
            "id": "Vbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
            "app_id": "A11111111111111111111111111111111",
            "bundle_id": "com.fixture.application",
            "platform": "ipa",
            "version": "1.2",
            "build": "12",
            "size_bytes": 123456,
            "package_type": "signed",
            "is_current": false,
            "created_at": 1793937600
        },
        "published_at": 1794592800
    }
}
任务尚在执行
HTTP 请求
GET /api/v1/apps/A11111111111111111111111111111111/jobs/Jcccccccccccccccccccccccccccccccc/result HTTP/1.1
Host: www.onesignios.com
Authorization: CS1-HMAC-SHA256 Credential=<AccessKey ID>,Signature=<签名>
X-Api-Date: <当前 UTC 时间>
X-Api-Nonce: <新生成的 32 位十六进制值>
X-Api-Content-Sha256: <正文摘要>
X-Api-Environment: production
Python 标准库调用
Python
from cloudsign_request import request

result = request(
    'GET',
    '/api/v1/apps/A11111111111111111111111111111111/jobs/Jcccccccccccccccccccccccccccccccc/result',
)
print(result["request_id"])
Python SDK 调用
Python SDK
import os
from cloudsign import Client

client = Client(
    "https://www.onesignios.com",
    os.environ["CLOUDSIGN_ACCESS_KEY_ID"],
    os.environ["CLOUDSIGN_ACCESS_KEY_SECRET"],
    os.environ.get("CLOUDSIGN_SECURITY_TOKEN", ""),
)

result = client.get_job_result(
    app='A11111111111111111111111111111111',
    job='Jcccccccccccccccccccccccccccccccc',
)
print(result["request_id"])
PHP SDK 调用
PHP SDK
<?php
declare(strict_types=1);

// Extract the PHP SDK source ZIP beside this file. Keep credentials on your server.
require_once __DIR__ . '/cloudsign-sdk/php/Client.php';
$requiredEnv = static function (string $name): string {
    $value = getenv($name);
    if ($value === false || $value === '') { throw new RuntimeException('Missing environment variable'); }
    return $value;
};
try {
    $client = new \Cloudsign\Sdk\Client(
        $requiredEnv('CLOUDSIGN_BASE_URL'),
        $requiredEnv('CLOUDSIGN_ACCESS_KEY_ID'),
        $requiredEnv('CLOUDSIGN_ACCESS_KEY_SECRET'),
        getenv('CLOUDSIGN_SECURITY_TOKEN') ?: '',
    );
    $result = $client->getJobResult(
        'A11111111111111111111111111111111',
        'Jcccccccccccccccccccccccccccccccc'
    );
    echo $result['request_id'], PHP_EOL;
} catch (\Cloudsign\Sdk\ApiError $error) {
    fwrite(STDERR, 'HTTP ' . $error->status . ' ' . $error->apiCode . '; RequestId: ' . $error->requestId . PHP_EOL);
    exit(1);
} catch (Throwable $error) {
    fwrite(STDERR, "Check SDK path, runtime and environment variables.\n");
    exit(1);
}
Node.js SDK 调用
Node.js SDK
// Node.js 20+ on a trusted server. Do not bundle this SDK in browsers or Vue.
import { ApiError, Client } from './cloudsign-sdk/node/client.mjs';

const requiredEnv = name => {
    const value = process.env[name];
    if (!value) throw new Error('Missing environment variable');
    return value;
};
try {
    const client = new Client(
        requiredEnv('CLOUDSIGN_BASE_URL'),
        requiredEnv('CLOUDSIGN_ACCESS_KEY_ID'),
        requiredEnv('CLOUDSIGN_ACCESS_KEY_SECRET'),
        process.env.CLOUDSIGN_SECURITY_TOKEN || '',
    );
    const result = await client.getJobResult(
        "A11111111111111111111111111111111",
        "Jcccccccccccccccccccccccccccccccc"
    );
    console.log(result.request_id);
} catch (error) {
    if (error instanceof ApiError) console.error(`HTTP ${error.status} ${error.code}; RequestId: ${error.requestId}`);
    else console.error('Check SDK path, runtime and environment variables.');
    process.exitCode = 1;
}
Go SDK 调用
Go SDK
// Go 1.22+, trusted server. Extract the Go SDK ZIP beside example.go.
package main

import (
    "context"
    "errors"
    "fmt"
    "os"
    "time"

    cloudsign "cloudsign/sdk"
)

func main() {
    fail := func(err error) {
        var api *cloudsign.APIError
        if errors.As(err, &api) {
            fmt.Fprintf(os.Stderr, "HTTP %d %s; RequestId: %s\n", api.Status, api.Code, api.RequestID)
        } else {
            fmt.Fprintln(os.Stderr, "Check SDK path, runtime and environment variables.")
        }
        os.Exit(1)
    }
    client, err := cloudsign.New(
        os.Getenv("CLOUDSIGN_BASE_URL"),
        os.Getenv("CLOUDSIGN_ACCESS_KEY_ID"),
        os.Getenv("CLOUDSIGN_ACCESS_KEY_SECRET"),
        os.Getenv("CLOUDSIGN_SECURITY_TOKEN"),
    )
    if err != nil { fail(err); return }
    ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
    defer cancel()
    result, err := client.GetJobResult(
		ctx,
		"A11111111111111111111111111111111",
		"Jcccccccccccccccccccccccccccccccc",
	)
    if err != nil { fail(err); return }
    fmt.Println(result.RequestID)
}
Java SDK 调用
Java SDK
// Java 17+, server-side. Extract the Java SDK ZIP beside Example.java.
import com.cloudsign.openapi.Client;
import java.util.*;

public class Example {
    private static String env(String name) {
        String value = System.getenv(name);
        if (value == null || value.isEmpty()) throw new IllegalArgumentException("Missing environment variable");
        return value;
    }
    private static Map<String,Object> object(Object... pairs) {
        var result = new LinkedHashMap<String,Object>();
        for (int i = 0; i < pairs.length; i += 2) result.put((String)pairs[i], pairs[i+1]);
        return result;
    }
    public static void main(String[] args) {
        try {
            var client = new Client(
                env("CLOUDSIGN_BASE_URL"),
                env("CLOUDSIGN_ACCESS_KEY_ID"),
                env("CLOUDSIGN_ACCESS_KEY_SECRET"),
                System.getenv().getOrDefault("CLOUDSIGN_SECURITY_TOKEN", "")
            );
            var result = client.getJobResult(
                "A11111111111111111111111111111111",
                "Jcccccccccccccccccccccccccccccccc"
            );
            System.out.println(result.requestId());
        } catch (Client.ApiException error) {
            System.err.printf("HTTP %d %s; RequestId: %s%n", error.status, error.code, error.requestId);
            System.exit(1);
        } catch (Exception error) {
            if (error instanceof InterruptedException) Thread.currentThread().interrupt();
            System.err.println("Check SDK path, runtime and environment variables.");
            System.exit(1);
        }
    }
}
Rust SDK 调用
Rust SDK
// Rust 1.88+, trusted server. Save as cloudsign-sdk/rust/examples/example.rs.
use cloudsign_openapi::{Client, Credentials, GetJobResult};
use serde_json::json;
use std::{env, error::Error};

async fn run() -> Result<(), Box<dyn Error>> {
    let origin = env::var("CLOUDSIGN_BASE_URL")?;
    let credentials = Credentials::new(
        env::var("CLOUDSIGN_ACCESS_KEY_ID")?,
        env::var("CLOUDSIGN_ACCESS_KEY_SECRET")?,
        env::var("CLOUDSIGN_SECURITY_TOKEN").ok().filter(|v| !v.is_empty()),
        None,
    )?;
    let client = Client::new(&origin, credentials)?;
    let input: GetJobResult = serde_json::from_value(json!({
        "app_id": "A11111111111111111111111111111111",
        "job_id": "Jcccccccccccccccccccccccccccccccc"
    }))?;
    let result = client.get_job_result(&input).await?;
    println!("{}", result.request_id);
    Ok(())
}

#[tokio::main]
async fn main() {
    if let Err(error) = run().await {
        if let Some(api) = error.downcast_ref::<cloudsign_openapi::Error>() {
            eprintln!("HTTP {} {}; RequestId: {}", api.status, api.code, api.request_id.as_deref().unwrap_or(""));
        } else {
            eprintln!("Check SDK path, runtime, environment variables and business input.");
        }
        std::process::exit(1);
    }
}
C SDK 调用

请求对象和响应对象的使用方式见C SDK 请求与响应。

C SDK
/* C11, trusted server. Save as example.c in the source ZIP root. */
#include <cloudsign/openapi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int copy_env(char *out, size_t capacity, const char *name, int required) {
    const char *value = getenv(name);
    if (!value || !*value) return !required;
    size_t length = strlen(value);
    if (length >= capacity) return 0;
    memcpy(out, value, length + 1);
    return 1;
}

int main(void) {
    cloudsign_credentials credentials = {0};
    cloudsign_client *client = NULL;
    cloudsign_result *result = NULL;
    cloudsign_decoded_response *decoded = NULL;
    cloudsign_built_request *built = NULL;
    cloudsign_status status = CLOUDSIGN_INVALID_CONFIGURATION;
    int initialized = 0, exit_code = 1;
    const char *origin = getenv("CLOUDSIGN_BASE_URL");
    if (!origin || !copy_env(credentials.access_key_id, sizeof(credentials.access_key_id), "CLOUDSIGN_ACCESS_KEY_ID", 1)
        || !copy_env(credentials.access_key_secret, sizeof(credentials.access_key_secret), "CLOUDSIGN_ACCESS_KEY_SECRET", 1)
        || !copy_env(credentials.security_token, sizeof(credentials.security_token), "CLOUDSIGN_SECURITY_TOKEN", 0)) goto done;
    status = cloudsign_global_init();
    if (status != CLOUDSIGN_OK) goto done;
    initialized = 1;
    cloudsign_options options = {.origin = origin, .credentials = &credentials, .timeout_ms = 15000};
    status = cloudsign_client_create(&options, &client);
    cloudsign_credentials_clear(&credentials);
    if (status != CLOUDSIGN_OK) goto done;
    const cloudsign_input_get_job_result input = {.presence_app_id = CLOUDSIGN_FIELD_VALUE, .app_id = "A11111111111111111111111111111111", .presence_job_id = CLOUDSIGN_FIELD_VALUE, .job_id = "Jcccccccccccccccccccccccccccccccc"};
    status = cloudsign_build_get_job_result(&input, &built);
    if (status != CLOUDSIGN_OK) goto done;
    status = cloudsign_send_built_request(client, built, &result);
    if (status == CLOUDSIGN_OK) {
        status = cloudsign_decode_get_job_result(result, &decoded);
        if (status != CLOUDSIGN_OK) goto done;
        const cloudsign_model_job_result *data = cloudsign_response_get_job_result(decoded);
        if (!data) { status = CLOUDSIGN_INVALID_RESPONSE; goto done; }
        /* Read typed fields here; NULL/absent is distinct from zero/false. */
        (void)data;
        puts(cloudsign_decoded_request_id(decoded));
        exit_code = 0;
    }
done:
    if (exit_code) {
        if (status == CLOUDSIGN_API_ERROR) fprintf(stderr, "HTTP %ld %s; RequestId: %s\n", cloudsign_result_http_status(result), cloudsign_result_error_code(result), cloudsign_result_request_id(result));
        else fputs("Check SDK path, runtime, environment variables and business input.\n", stderr);
    }
    cloudsign_result_free(result);
    cloudsign_decoded_free(decoded);
    cloudsign_built_request_free(built);
    cloudsign_client_free(client);
    if (initialized) cloudsign_global_cleanup();
    cloudsign_credentials_clear(&credentials);
    return exit_code;
}
JSON 响应
{
    "request_id": "00000000000000000000000000000000",
    "data": {
        "app_id": "A11111111111111111111111111111111",
        "job_id": "Jcccccccccccccccccccccccccccccccc",
        "status": "running",
        "terminal": false,
        "result_state": "pending",
        "source_version": {
            "id": "Vaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            "app_id": "A11111111111111111111111111111111",
            "bundle_id": "com.fixture.application",
            "platform": "ipa",
            "version": "1.2",
            "build": "12",
            "size_bytes": 123456,
            "package_type": "original",
            "is_current": true,
            "created_at": 1793937600
        },
        "signed_version": null,
        "published_at": null
    }
}
任务失败
HTTP 请求
GET /api/v1/apps/A11111111111111111111111111111111/jobs/Jcccccccccccccccccccccccccccccccc/result HTTP/1.1
Host: www.onesignios.com
Authorization: CS1-HMAC-SHA256 Credential=<AccessKey ID>,Signature=<签名>
X-Api-Date: <当前 UTC 时间>
X-Api-Nonce: <新生成的 32 位十六进制值>
X-Api-Content-Sha256: <正文摘要>
X-Api-Environment: production
Python 标准库调用
Python
from cloudsign_request import request

result = request(
    'GET',
    '/api/v1/apps/A11111111111111111111111111111111/jobs/Jcccccccccccccccccccccccccccccccc/result',
)
print(result["request_id"])
Python SDK 调用
Python SDK
import os
from cloudsign import Client

client = Client(
    "https://www.onesignios.com",
    os.environ["CLOUDSIGN_ACCESS_KEY_ID"],
    os.environ["CLOUDSIGN_ACCESS_KEY_SECRET"],
    os.environ.get("CLOUDSIGN_SECURITY_TOKEN", ""),
)

result = client.get_job_result(
    app='A11111111111111111111111111111111',
    job='Jcccccccccccccccccccccccccccccccc',
)
print(result["request_id"])
PHP SDK 调用
PHP SDK
<?php
declare(strict_types=1);

// Extract the PHP SDK source ZIP beside this file. Keep credentials on your server.
require_once __DIR__ . '/cloudsign-sdk/php/Client.php';
$requiredEnv = static function (string $name): string {
    $value = getenv($name);
    if ($value === false || $value === '') { throw new RuntimeException('Missing environment variable'); }
    return $value;
};
try {
    $client = new \Cloudsign\Sdk\Client(
        $requiredEnv('CLOUDSIGN_BASE_URL'),
        $requiredEnv('CLOUDSIGN_ACCESS_KEY_ID'),
        $requiredEnv('CLOUDSIGN_ACCESS_KEY_SECRET'),
        getenv('CLOUDSIGN_SECURITY_TOKEN') ?: '',
    );
    $result = $client->getJobResult(
        'A11111111111111111111111111111111',
        'Jcccccccccccccccccccccccccccccccc'
    );
    echo $result['request_id'], PHP_EOL;
} catch (\Cloudsign\Sdk\ApiError $error) {
    fwrite(STDERR, 'HTTP ' . $error->status . ' ' . $error->apiCode . '; RequestId: ' . $error->requestId . PHP_EOL);
    exit(1);
} catch (Throwable $error) {
    fwrite(STDERR, "Check SDK path, runtime and environment variables.\n");
    exit(1);
}
Node.js SDK 调用
Node.js SDK
// Node.js 20+ on a trusted server. Do not bundle this SDK in browsers or Vue.
import { ApiError, Client } from './cloudsign-sdk/node/client.mjs';

const requiredEnv = name => {
    const value = process.env[name];
    if (!value) throw new Error('Missing environment variable');
    return value;
};
try {
    const client = new Client(
        requiredEnv('CLOUDSIGN_BASE_URL'),
        requiredEnv('CLOUDSIGN_ACCESS_KEY_ID'),
        requiredEnv('CLOUDSIGN_ACCESS_KEY_SECRET'),
        process.env.CLOUDSIGN_SECURITY_TOKEN || '',
    );
    const result = await client.getJobResult(
        "A11111111111111111111111111111111",
        "Jcccccccccccccccccccccccccccccccc"
    );
    console.log(result.request_id);
} catch (error) {
    if (error instanceof ApiError) console.error(`HTTP ${error.status} ${error.code}; RequestId: ${error.requestId}`);
    else console.error('Check SDK path, runtime and environment variables.');
    process.exitCode = 1;
}
Go SDK 调用
Go SDK
// Go 1.22+, trusted server. Extract the Go SDK ZIP beside example.go.
package main

import (
    "context"
    "errors"
    "fmt"
    "os"
    "time"

    cloudsign "cloudsign/sdk"
)

func main() {
    fail := func(err error) {
        var api *cloudsign.APIError
        if errors.As(err, &api) {
            fmt.Fprintf(os.Stderr, "HTTP %d %s; RequestId: %s\n", api.Status, api.Code, api.RequestID)
        } else {
            fmt.Fprintln(os.Stderr, "Check SDK path, runtime and environment variables.")
        }
        os.Exit(1)
    }
    client, err := cloudsign.New(
        os.Getenv("CLOUDSIGN_BASE_URL"),
        os.Getenv("CLOUDSIGN_ACCESS_KEY_ID"),
        os.Getenv("CLOUDSIGN_ACCESS_KEY_SECRET"),
        os.Getenv("CLOUDSIGN_SECURITY_TOKEN"),
    )
    if err != nil { fail(err); return }
    ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
    defer cancel()
    result, err := client.GetJobResult(
		ctx,
		"A11111111111111111111111111111111",
		"Jcccccccccccccccccccccccccccccccc",
	)
    if err != nil { fail(err); return }
    fmt.Println(result.RequestID)
}
Java SDK 调用
Java SDK
// Java 17+, server-side. Extract the Java SDK ZIP beside Example.java.
import com.cloudsign.openapi.Client;
import java.util.*;

public class Example {
    private static String env(String name) {
        String value = System.getenv(name);
        if (value == null || value.isEmpty()) throw new IllegalArgumentException("Missing environment variable");
        return value;
    }
    private static Map<String,Object> object(Object... pairs) {
        var result = new LinkedHashMap<String,Object>();
        for (int i = 0; i < pairs.length; i += 2) result.put((String)pairs[i], pairs[i+1]);
        return result;
    }
    public static void main(String[] args) {
        try {
            var client = new Client(
                env("CLOUDSIGN_BASE_URL"),
                env("CLOUDSIGN_ACCESS_KEY_ID"),
                env("CLOUDSIGN_ACCESS_KEY_SECRET"),
                System.getenv().getOrDefault("CLOUDSIGN_SECURITY_TOKEN", "")
            );
            var result = client.getJobResult(
                "A11111111111111111111111111111111",
                "Jcccccccccccccccccccccccccccccccc"
            );
            System.out.println(result.requestId());
        } catch (Client.ApiException error) {
            System.err.printf("HTTP %d %s; RequestId: %s%n", error.status, error.code, error.requestId);
            System.exit(1);
        } catch (Exception error) {
            if (error instanceof InterruptedException) Thread.currentThread().interrupt();
            System.err.println("Check SDK path, runtime and environment variables.");
            System.exit(1);
        }
    }
}
Rust SDK 调用
Rust SDK
// Rust 1.88+, trusted server. Save as cloudsign-sdk/rust/examples/example.rs.
use cloudsign_openapi::{Client, Credentials, GetJobResult};
use serde_json::json;
use std::{env, error::Error};

async fn run() -> Result<(), Box<dyn Error>> {
    let origin = env::var("CLOUDSIGN_BASE_URL")?;
    let credentials = Credentials::new(
        env::var("CLOUDSIGN_ACCESS_KEY_ID")?,
        env::var("CLOUDSIGN_ACCESS_KEY_SECRET")?,
        env::var("CLOUDSIGN_SECURITY_TOKEN").ok().filter(|v| !v.is_empty()),
        None,
    )?;
    let client = Client::new(&origin, credentials)?;
    let input: GetJobResult = serde_json::from_value(json!({
        "app_id": "A11111111111111111111111111111111",
        "job_id": "Jcccccccccccccccccccccccccccccccc"
    }))?;
    let result = client.get_job_result(&input).await?;
    println!("{}", result.request_id);
    Ok(())
}

#[tokio::main]
async fn main() {
    if let Err(error) = run().await {
        if let Some(api) = error.downcast_ref::<cloudsign_openapi::Error>() {
            eprintln!("HTTP {} {}; RequestId: {}", api.status, api.code, api.request_id.as_deref().unwrap_or(""));
        } else {
            eprintln!("Check SDK path, runtime, environment variables and business input.");
        }
        std::process::exit(1);
    }
}
C SDK 调用

请求对象和响应对象的使用方式见C SDK 请求与响应。

C SDK
/* C11, trusted server. Save as example.c in the source ZIP root. */
#include <cloudsign/openapi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int copy_env(char *out, size_t capacity, const char *name, int required) {
    const char *value = getenv(name);
    if (!value || !*value) return !required;
    size_t length = strlen(value);
    if (length >= capacity) return 0;
    memcpy(out, value, length + 1);
    return 1;
}

int main(void) {
    cloudsign_credentials credentials = {0};
    cloudsign_client *client = NULL;
    cloudsign_result *result = NULL;
    cloudsign_decoded_response *decoded = NULL;
    cloudsign_built_request *built = NULL;
    cloudsign_status status = CLOUDSIGN_INVALID_CONFIGURATION;
    int initialized = 0, exit_code = 1;
    const char *origin = getenv("CLOUDSIGN_BASE_URL");
    if (!origin || !copy_env(credentials.access_key_id, sizeof(credentials.access_key_id), "CLOUDSIGN_ACCESS_KEY_ID", 1)
        || !copy_env(credentials.access_key_secret, sizeof(credentials.access_key_secret), "CLOUDSIGN_ACCESS_KEY_SECRET", 1)
        || !copy_env(credentials.security_token, sizeof(credentials.security_token), "CLOUDSIGN_SECURITY_TOKEN", 0)) goto done;
    status = cloudsign_global_init();
    if (status != CLOUDSIGN_OK) goto done;
    initialized = 1;
    cloudsign_options options = {.origin = origin, .credentials = &credentials, .timeout_ms = 15000};
    status = cloudsign_client_create(&options, &client);
    cloudsign_credentials_clear(&credentials);
    if (status != CLOUDSIGN_OK) goto done;
    const cloudsign_input_get_job_result input = {.presence_app_id = CLOUDSIGN_FIELD_VALUE, .app_id = "A11111111111111111111111111111111", .presence_job_id = CLOUDSIGN_FIELD_VALUE, .job_id = "Jcccccccccccccccccccccccccccccccc"};
    status = cloudsign_build_get_job_result(&input, &built);
    if (status != CLOUDSIGN_OK) goto done;
    status = cloudsign_send_built_request(client, built, &result);
    if (status == CLOUDSIGN_OK) {
        status = cloudsign_decode_get_job_result(result, &decoded);
        if (status != CLOUDSIGN_OK) goto done;
        const cloudsign_model_job_result *data = cloudsign_response_get_job_result(decoded);
        if (!data) { status = CLOUDSIGN_INVALID_RESPONSE; goto done; }
        /* Read typed fields here; NULL/absent is distinct from zero/false. */
        (void)data;
        puts(cloudsign_decoded_request_id(decoded));
        exit_code = 0;
    }
done:
    if (exit_code) {
        if (status == CLOUDSIGN_API_ERROR) fprintf(stderr, "HTTP %ld %s; RequestId: %s\n", cloudsign_result_http_status(result), cloudsign_result_error_code(result), cloudsign_result_request_id(result));
        else fputs("Check SDK path, runtime, environment variables and business input.\n", stderr);
    }
    cloudsign_result_free(result);
    cloudsign_decoded_free(decoded);
    cloudsign_built_request_free(built);
    cloudsign_client_free(client);
    if (initialized) cloudsign_global_cleanup();
    cloudsign_credentials_clear(&credentials);
    return exit_code;
}
JSON 响应
{
    "request_id": "00000000000000000000000000000000",
    "data": {
        "app_id": "A11111111111111111111111111111111",
        "job_id": "Jcccccccccccccccccccccccccccccccc",
        "status": "failed",
        "terminal": true,
        "result_state": "not_produced",
        "source_version": {
            "id": "Vaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            "app_id": "A11111111111111111111111111111111",
            "bundle_id": "com.fixture.application",
            "platform": "ipa",
            "version": "1.2",
            "build": "12",
            "size_bytes": 123456,
            "package_type": "original",
            "is_current": true,
            "created_at": 1793937600
        },
        "signed_version": null,
        "published_at": null
    }
}
旧任务无可信关联
HTTP 请求
GET /api/v1/apps/A11111111111111111111111111111111/jobs/Jcccccccccccccccccccccccccccccccc/result HTTP/1.1
Host: www.onesignios.com
Authorization: CS1-HMAC-SHA256 Credential=<AccessKey ID>,Signature=<签名>
X-Api-Date: <当前 UTC 时间>
X-Api-Nonce: <新生成的 32 位十六进制值>
X-Api-Content-Sha256: <正文摘要>
X-Api-Environment: production
Python 标准库调用
Python
from cloudsign_request import request

result = request(
    'GET',
    '/api/v1/apps/A11111111111111111111111111111111/jobs/Jcccccccccccccccccccccccccccccccc/result',
)
print(result["request_id"])
Python SDK 调用
Python SDK
import os
from cloudsign import Client

client = Client(
    "https://www.onesignios.com",
    os.environ["CLOUDSIGN_ACCESS_KEY_ID"],
    os.environ["CLOUDSIGN_ACCESS_KEY_SECRET"],
    os.environ.get("CLOUDSIGN_SECURITY_TOKEN", ""),
)

result = client.get_job_result(
    app='A11111111111111111111111111111111',
    job='Jcccccccccccccccccccccccccccccccc',
)
print(result["request_id"])
PHP SDK 调用
PHP SDK
<?php
declare(strict_types=1);

// Extract the PHP SDK source ZIP beside this file. Keep credentials on your server.
require_once __DIR__ . '/cloudsign-sdk/php/Client.php';
$requiredEnv = static function (string $name): string {
    $value = getenv($name);
    if ($value === false || $value === '') { throw new RuntimeException('Missing environment variable'); }
    return $value;
};
try {
    $client = new \Cloudsign\Sdk\Client(
        $requiredEnv('CLOUDSIGN_BASE_URL'),
        $requiredEnv('CLOUDSIGN_ACCESS_KEY_ID'),
        $requiredEnv('CLOUDSIGN_ACCESS_KEY_SECRET'),
        getenv('CLOUDSIGN_SECURITY_TOKEN') ?: '',
    );
    $result = $client->getJobResult(
        'A11111111111111111111111111111111',
        'Jcccccccccccccccccccccccccccccccc'
    );
    echo $result['request_id'], PHP_EOL;
} catch (\Cloudsign\Sdk\ApiError $error) {
    fwrite(STDERR, 'HTTP ' . $error->status . ' ' . $error->apiCode . '; RequestId: ' . $error->requestId . PHP_EOL);
    exit(1);
} catch (Throwable $error) {
    fwrite(STDERR, "Check SDK path, runtime and environment variables.\n");
    exit(1);
}
Node.js SDK 调用
Node.js SDK
// Node.js 20+ on a trusted server. Do not bundle this SDK in browsers or Vue.
import { ApiError, Client } from './cloudsign-sdk/node/client.mjs';

const requiredEnv = name => {
    const value = process.env[name];
    if (!value) throw new Error('Missing environment variable');
    return value;
};
try {
    const client = new Client(
        requiredEnv('CLOUDSIGN_BASE_URL'),
        requiredEnv('CLOUDSIGN_ACCESS_KEY_ID'),
        requiredEnv('CLOUDSIGN_ACCESS_KEY_SECRET'),
        process.env.CLOUDSIGN_SECURITY_TOKEN || '',
    );
    const result = await client.getJobResult(
        "A11111111111111111111111111111111",
        "Jcccccccccccccccccccccccccccccccc"
    );
    console.log(result.request_id);
} catch (error) {
    if (error instanceof ApiError) console.error(`HTTP ${error.status} ${error.code}; RequestId: ${error.requestId}`);
    else console.error('Check SDK path, runtime and environment variables.');
    process.exitCode = 1;
}
Go SDK 调用
Go SDK
// Go 1.22+, trusted server. Extract the Go SDK ZIP beside example.go.
package main

import (
    "context"
    "errors"
    "fmt"
    "os"
    "time"

    cloudsign "cloudsign/sdk"
)

func main() {
    fail := func(err error) {
        var api *cloudsign.APIError
        if errors.As(err, &api) {
            fmt.Fprintf(os.Stderr, "HTTP %d %s; RequestId: %s\n", api.Status, api.Code, api.RequestID)
        } else {
            fmt.Fprintln(os.Stderr, "Check SDK path, runtime and environment variables.")
        }
        os.Exit(1)
    }
    client, err := cloudsign.New(
        os.Getenv("CLOUDSIGN_BASE_URL"),
        os.Getenv("CLOUDSIGN_ACCESS_KEY_ID"),
        os.Getenv("CLOUDSIGN_ACCESS_KEY_SECRET"),
        os.Getenv("CLOUDSIGN_SECURITY_TOKEN"),
    )
    if err != nil { fail(err); return }
    ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
    defer cancel()
    result, err := client.GetJobResult(
		ctx,
		"A11111111111111111111111111111111",
		"Jcccccccccccccccccccccccccccccccc",
	)
    if err != nil { fail(err); return }
    fmt.Println(result.RequestID)
}
Java SDK 调用
Java SDK
// Java 17+, server-side. Extract the Java SDK ZIP beside Example.java.
import com.cloudsign.openapi.Client;
import java.util.*;

public class Example {
    private static String env(String name) {
        String value = System.getenv(name);
        if (value == null || value.isEmpty()) throw new IllegalArgumentException("Missing environment variable");
        return value;
    }
    private static Map<String,Object> object(Object... pairs) {
        var result = new LinkedHashMap<String,Object>();
        for (int i = 0; i < pairs.length; i += 2) result.put((String)pairs[i], pairs[i+1]);
        return result;
    }
    public static void main(String[] args) {
        try {
            var client = new Client(
                env("CLOUDSIGN_BASE_URL"),
                env("CLOUDSIGN_ACCESS_KEY_ID"),
                env("CLOUDSIGN_ACCESS_KEY_SECRET"),
                System.getenv().getOrDefault("CLOUDSIGN_SECURITY_TOKEN", "")
            );
            var result = client.getJobResult(
                "A11111111111111111111111111111111",
                "Jcccccccccccccccccccccccccccccccc"
            );
            System.out.println(result.requestId());
        } catch (Client.ApiException error) {
            System.err.printf("HTTP %d %s; RequestId: %s%n", error.status, error.code, error.requestId);
            System.exit(1);
        } catch (Exception error) {
            if (error instanceof InterruptedException) Thread.currentThread().interrupt();
            System.err.println("Check SDK path, runtime and environment variables.");
            System.exit(1);
        }
    }
}
Rust SDK 调用
Rust SDK
// Rust 1.88+, trusted server. Save as cloudsign-sdk/rust/examples/example.rs.
use cloudsign_openapi::{Client, Credentials, GetJobResult};
use serde_json::json;
use std::{env, error::Error};

async fn run() -> Result<(), Box<dyn Error>> {
    let origin = env::var("CLOUDSIGN_BASE_URL")?;
    let credentials = Credentials::new(
        env::var("CLOUDSIGN_ACCESS_KEY_ID")?,
        env::var("CLOUDSIGN_ACCESS_KEY_SECRET")?,
        env::var("CLOUDSIGN_SECURITY_TOKEN").ok().filter(|v| !v.is_empty()),
        None,
    )?;
    let client = Client::new(&origin, credentials)?;
    let input: GetJobResult = serde_json::from_value(json!({
        "app_id": "A11111111111111111111111111111111",
        "job_id": "Jcccccccccccccccccccccccccccccccc"
    }))?;
    let result = client.get_job_result(&input).await?;
    println!("{}", result.request_id);
    Ok(())
}

#[tokio::main]
async fn main() {
    if let Err(error) = run().await {
        if let Some(api) = error.downcast_ref::<cloudsign_openapi::Error>() {
            eprintln!("HTTP {} {}; RequestId: {}", api.status, api.code, api.request_id.as_deref().unwrap_or(""));
        } else {
            eprintln!("Check SDK path, runtime, environment variables and business input.");
        }
        std::process::exit(1);
    }
}
C SDK 调用

请求对象和响应对象的使用方式见C SDK 请求与响应。

C SDK
/* C11, trusted server. Save as example.c in the source ZIP root. */
#include <cloudsign/openapi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int copy_env(char *out, size_t capacity, const char *name, int required) {
    const char *value = getenv(name);
    if (!value || !*value) return !required;
    size_t length = strlen(value);
    if (length >= capacity) return 0;
    memcpy(out, value, length + 1);
    return 1;
}

int main(void) {
    cloudsign_credentials credentials = {0};
    cloudsign_client *client = NULL;
    cloudsign_result *result = NULL;
    cloudsign_decoded_response *decoded = NULL;
    cloudsign_built_request *built = NULL;
    cloudsign_status status = CLOUDSIGN_INVALID_CONFIGURATION;
    int initialized = 0, exit_code = 1;
    const char *origin = getenv("CLOUDSIGN_BASE_URL");
    if (!origin || !copy_env(credentials.access_key_id, sizeof(credentials.access_key_id), "CLOUDSIGN_ACCESS_KEY_ID", 1)
        || !copy_env(credentials.access_key_secret, sizeof(credentials.access_key_secret), "CLOUDSIGN_ACCESS_KEY_SECRET", 1)
        || !copy_env(credentials.security_token, sizeof(credentials.security_token), "CLOUDSIGN_SECURITY_TOKEN", 0)) goto done;
    status = cloudsign_global_init();
    if (status != CLOUDSIGN_OK) goto done;
    initialized = 1;
    cloudsign_options options = {.origin = origin, .credentials = &credentials, .timeout_ms = 15000};
    status = cloudsign_client_create(&options, &client);
    cloudsign_credentials_clear(&credentials);
    if (status != CLOUDSIGN_OK) goto done;
    const cloudsign_input_get_job_result input = {.presence_app_id = CLOUDSIGN_FIELD_VALUE, .app_id = "A11111111111111111111111111111111", .presence_job_id = CLOUDSIGN_FIELD_VALUE, .job_id = "Jcccccccccccccccccccccccccccccccc"};
    status = cloudsign_build_get_job_result(&input, &built);
    if (status != CLOUDSIGN_OK) goto done;
    status = cloudsign_send_built_request(client, built, &result);
    if (status == CLOUDSIGN_OK) {
        status = cloudsign_decode_get_job_result(result, &decoded);
        if (status != CLOUDSIGN_OK) goto done;
        const cloudsign_model_job_result *data = cloudsign_response_get_job_result(decoded);
        if (!data) { status = CLOUDSIGN_INVALID_RESPONSE; goto done; }
        /* Read typed fields here; NULL/absent is distinct from zero/false. */
        (void)data;
        puts(cloudsign_decoded_request_id(decoded));
        exit_code = 0;
    }
done:
    if (exit_code) {
        if (status == CLOUDSIGN_API_ERROR) fprintf(stderr, "HTTP %ld %s; RequestId: %s\n", cloudsign_result_http_status(result), cloudsign_result_error_code(result), cloudsign_result_request_id(result));
        else fputs("Check SDK path, runtime, environment variables and business input.\n", stderr);
    }
    cloudsign_result_free(result);
    cloudsign_decoded_free(decoded);
    cloudsign_built_request_free(built);
    cloudsign_client_free(client);
    if (initialized) cloudsign_global_cleanup();
    cloudsign_credentials_clear(&credentials);
    return exit_code;
}
JSON 响应
{
    "request_id": "00000000000000000000000000000000",
    "data": {
        "app_id": "A11111111111111111111111111111111",
        "job_id": "Jcccccccccccccccccccccccccccccccc",
        "status": "succeeded",
        "terminal": true,
        "result_state": "not_recorded",
        "source_version": {
            "id": "Vaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            "app_id": "A11111111111111111111111111111111",
            "bundle_id": "com.fixture.application",
            "platform": "ipa",
            "version": "1.2",
            "build": "12",
            "size_bytes": 123456,
            "package_type": "original",
            "is_current": true,
            "created_at": 1793937600
        },
        "signed_version": null,
        "published_at": null
    }
}
产物已清理
HTTP 请求
GET /api/v1/apps/A11111111111111111111111111111111/jobs/Jcccccccccccccccccccccccccccccccc/result HTTP/1.1
Host: www.onesignios.com
Authorization: CS1-HMAC-SHA256 Credential=<AccessKey ID>,Signature=<签名>
X-Api-Date: <当前 UTC 时间>
X-Api-Nonce: <新生成的 32 位十六进制值>
X-Api-Content-Sha256: <正文摘要>
X-Api-Environment: production
Python 标准库调用
Python
from cloudsign_request import request

result = request(
    'GET',
    '/api/v1/apps/A11111111111111111111111111111111/jobs/Jcccccccccccccccccccccccccccccccc/result',
)
print(result["request_id"])
Python SDK 调用
Python SDK
import os
from cloudsign import Client

client = Client(
    "https://www.onesignios.com",
    os.environ["CLOUDSIGN_ACCESS_KEY_ID"],
    os.environ["CLOUDSIGN_ACCESS_KEY_SECRET"],
    os.environ.get("CLOUDSIGN_SECURITY_TOKEN", ""),
)

result = client.get_job_result(
    app='A11111111111111111111111111111111',
    job='Jcccccccccccccccccccccccccccccccc',
)
print(result["request_id"])
PHP SDK 调用
PHP SDK
<?php
declare(strict_types=1);

// Extract the PHP SDK source ZIP beside this file. Keep credentials on your server.
require_once __DIR__ . '/cloudsign-sdk/php/Client.php';
$requiredEnv = static function (string $name): string {
    $value = getenv($name);
    if ($value === false || $value === '') { throw new RuntimeException('Missing environment variable'); }
    return $value;
};
try {
    $client = new \Cloudsign\Sdk\Client(
        $requiredEnv('CLOUDSIGN_BASE_URL'),
        $requiredEnv('CLOUDSIGN_ACCESS_KEY_ID'),
        $requiredEnv('CLOUDSIGN_ACCESS_KEY_SECRET'),
        getenv('CLOUDSIGN_SECURITY_TOKEN') ?: '',
    );
    $result = $client->getJobResult(
        'A11111111111111111111111111111111',
        'Jcccccccccccccccccccccccccccccccc'
    );
    echo $result['request_id'], PHP_EOL;
} catch (\Cloudsign\Sdk\ApiError $error) {
    fwrite(STDERR, 'HTTP ' . $error->status . ' ' . $error->apiCode . '; RequestId: ' . $error->requestId . PHP_EOL);
    exit(1);
} catch (Throwable $error) {
    fwrite(STDERR, "Check SDK path, runtime and environment variables.\n");
    exit(1);
}
Node.js SDK 调用
Node.js SDK
// Node.js 20+ on a trusted server. Do not bundle this SDK in browsers or Vue.
import { ApiError, Client } from './cloudsign-sdk/node/client.mjs';

const requiredEnv = name => {
    const value = process.env[name];
    if (!value) throw new Error('Missing environment variable');
    return value;
};
try {
    const client = new Client(
        requiredEnv('CLOUDSIGN_BASE_URL'),
        requiredEnv('CLOUDSIGN_ACCESS_KEY_ID'),
        requiredEnv('CLOUDSIGN_ACCESS_KEY_SECRET'),
        process.env.CLOUDSIGN_SECURITY_TOKEN || '',
    );
    const result = await client.getJobResult(
        "A11111111111111111111111111111111",
        "Jcccccccccccccccccccccccccccccccc"
    );
    console.log(result.request_id);
} catch (error) {
    if (error instanceof ApiError) console.error(`HTTP ${error.status} ${error.code}; RequestId: ${error.requestId}`);
    else console.error('Check SDK path, runtime and environment variables.');
    process.exitCode = 1;
}
Go SDK 调用
Go SDK
// Go 1.22+, trusted server. Extract the Go SDK ZIP beside example.go.
package main

import (
    "context"
    "errors"
    "fmt"
    "os"
    "time"

    cloudsign "cloudsign/sdk"
)

func main() {
    fail := func(err error) {
        var api *cloudsign.APIError
        if errors.As(err, &api) {
            fmt.Fprintf(os.Stderr, "HTTP %d %s; RequestId: %s\n", api.Status, api.Code, api.RequestID)
        } else {
            fmt.Fprintln(os.Stderr, "Check SDK path, runtime and environment variables.")
        }
        os.Exit(1)
    }
    client, err := cloudsign.New(
        os.Getenv("CLOUDSIGN_BASE_URL"),
        os.Getenv("CLOUDSIGN_ACCESS_KEY_ID"),
        os.Getenv("CLOUDSIGN_ACCESS_KEY_SECRET"),
        os.Getenv("CLOUDSIGN_SECURITY_TOKEN"),
    )
    if err != nil { fail(err); return }
    ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
    defer cancel()
    result, err := client.GetJobResult(
		ctx,
		"A11111111111111111111111111111111",
		"Jcccccccccccccccccccccccccccccccc",
	)
    if err != nil { fail(err); return }
    fmt.Println(result.RequestID)
}
Java SDK 调用
Java SDK
// Java 17+, server-side. Extract the Java SDK ZIP beside Example.java.
import com.cloudsign.openapi.Client;
import java.util.*;

public class Example {
    private static String env(String name) {
        String value = System.getenv(name);
        if (value == null || value.isEmpty()) throw new IllegalArgumentException("Missing environment variable");
        return value;
    }
    private static Map<String,Object> object(Object... pairs) {
        var result = new LinkedHashMap<String,Object>();
        for (int i = 0; i < pairs.length; i += 2) result.put((String)pairs[i], pairs[i+1]);
        return result;
    }
    public static void main(String[] args) {
        try {
            var client = new Client(
                env("CLOUDSIGN_BASE_URL"),
                env("CLOUDSIGN_ACCESS_KEY_ID"),
                env("CLOUDSIGN_ACCESS_KEY_SECRET"),
                System.getenv().getOrDefault("CLOUDSIGN_SECURITY_TOKEN", "")
            );
            var result = client.getJobResult(
                "A11111111111111111111111111111111",
                "Jcccccccccccccccccccccccccccccccc"
            );
            System.out.println(result.requestId());
        } catch (Client.ApiException error) {
            System.err.printf("HTTP %d %s; RequestId: %s%n", error.status, error.code, error.requestId);
            System.exit(1);
        } catch (Exception error) {
            if (error instanceof InterruptedException) Thread.currentThread().interrupt();
            System.err.println("Check SDK path, runtime and environment variables.");
            System.exit(1);
        }
    }
}
Rust SDK 调用
Rust SDK
// Rust 1.88+, trusted server. Save as cloudsign-sdk/rust/examples/example.rs.
use cloudsign_openapi::{Client, Credentials, GetJobResult};
use serde_json::json;
use std::{env, error::Error};

async fn run() -> Result<(), Box<dyn Error>> {
    let origin = env::var("CLOUDSIGN_BASE_URL")?;
    let credentials = Credentials::new(
        env::var("CLOUDSIGN_ACCESS_KEY_ID")?,
        env::var("CLOUDSIGN_ACCESS_KEY_SECRET")?,
        env::var("CLOUDSIGN_SECURITY_TOKEN").ok().filter(|v| !v.is_empty()),
        None,
    )?;
    let client = Client::new(&origin, credentials)?;
    let input: GetJobResult = serde_json::from_value(json!({
        "app_id": "A11111111111111111111111111111111",
        "job_id": "Jcccccccccccccccccccccccccccccccc"
    }))?;
    let result = client.get_job_result(&input).await?;
    println!("{}", result.request_id);
    Ok(())
}

#[tokio::main]
async fn main() {
    if let Err(error) = run().await {
        if let Some(api) = error.downcast_ref::<cloudsign_openapi::Error>() {
            eprintln!("HTTP {} {}; RequestId: {}", api.status, api.code, api.request_id.as_deref().unwrap_or(""));
        } else {
            eprintln!("Check SDK path, runtime, environment variables and business input.");
        }
        std::process::exit(1);
    }
}
C SDK 调用

请求对象和响应对象的使用方式见C SDK 请求与响应。

C SDK
/* C11, trusted server. Save as example.c in the source ZIP root. */
#include <cloudsign/openapi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int copy_env(char *out, size_t capacity, const char *name, int required) {
    const char *value = getenv(name);
    if (!value || !*value) return !required;
    size_t length = strlen(value);
    if (length >= capacity) return 0;
    memcpy(out, value, length + 1);
    return 1;
}

int main(void) {
    cloudsign_credentials credentials = {0};
    cloudsign_client *client = NULL;
    cloudsign_result *result = NULL;
    cloudsign_decoded_response *decoded = NULL;
    cloudsign_built_request *built = NULL;
    cloudsign_status status = CLOUDSIGN_INVALID_CONFIGURATION;
    int initialized = 0, exit_code = 1;
    const char *origin = getenv("CLOUDSIGN_BASE_URL");
    if (!origin || !copy_env(credentials.access_key_id, sizeof(credentials.access_key_id), "CLOUDSIGN_ACCESS_KEY_ID", 1)
        || !copy_env(credentials.access_key_secret, sizeof(credentials.access_key_secret), "CLOUDSIGN_ACCESS_KEY_SECRET", 1)
        || !copy_env(credentials.security_token, sizeof(credentials.security_token), "CLOUDSIGN_SECURITY_TOKEN", 0)) goto done;
    status = cloudsign_global_init();
    if (status != CLOUDSIGN_OK) goto done;
    initialized = 1;
    cloudsign_options options = {.origin = origin, .credentials = &credentials, .timeout_ms = 15000};
    status = cloudsign_client_create(&options, &client);
    cloudsign_credentials_clear(&credentials);
    if (status != CLOUDSIGN_OK) goto done;
    const cloudsign_input_get_job_result input = {.presence_app_id = CLOUDSIGN_FIELD_VALUE, .app_id = "A11111111111111111111111111111111", .presence_job_id = CLOUDSIGN_FIELD_VALUE, .job_id = "Jcccccccccccccccccccccccccccccccc"};
    status = cloudsign_build_get_job_result(&input, &built);
    if (status != CLOUDSIGN_OK) goto done;
    status = cloudsign_send_built_request(client, built, &result);
    if (status == CLOUDSIGN_OK) {
        status = cloudsign_decode_get_job_result(result, &decoded);
        if (status != CLOUDSIGN_OK) goto done;
        const cloudsign_model_job_result *data = cloudsign_response_get_job_result(decoded);
        if (!data) { status = CLOUDSIGN_INVALID_RESPONSE; goto done; }
        /* Read typed fields here; NULL/absent is distinct from zero/false. */
        (void)data;
        puts(cloudsign_decoded_request_id(decoded));
        exit_code = 0;
    }
done:
    if (exit_code) {
        if (status == CLOUDSIGN_API_ERROR) fprintf(stderr, "HTTP %ld %s; RequestId: %s\n", cloudsign_result_http_status(result), cloudsign_result_error_code(result), cloudsign_result_request_id(result));
        else fputs("Check SDK path, runtime, environment variables and business input.\n", stderr);
    }
    cloudsign_result_free(result);
    cloudsign_decoded_free(decoded);
    cloudsign_built_request_free(built);
    cloudsign_client_free(client);
    if (initialized) cloudsign_global_cleanup();
    cloudsign_credentials_clear(&credentials);
    return exit_code;
}
JSON 响应
{
    "request_id": "00000000000000000000000000000000",
    "data": {
        "app_id": "A11111111111111111111111111111111",
        "job_id": "Jcccccccccccccccccccccccccccccccc",
        "status": "succeeded",
        "terminal": true,
        "result_state": "removed",
        "source_version": null,
        "signed_version": null,
        "published_at": 1794592800
    }
}

错误处理

失败或中断后

JobResultUnavailable 时保留原任务稍后重试。结果已清理或缺少历史关联时,向使用者说明原因;需要新产物时明确发起新签名。

相关错误码

HTTP错误码处理方式
404NotFound核对路径中各标识是否完整、属于同一业务应用且在当前授权范围内。
403AccessDenied检查当前身份的动作、资源范围、来源 IP 及功能准入。
400InvalidQuery检查参数名称、格式、范围和 URI 编码,删除重复参数。
503JobResultUnavailable暂时无法关联任务与签名产物。保存应用 ID、签名任务 ID 和 request_id,稍后查询原任务,不用版本列表第一项代替。
401InvalidCredentials凭据无效、已停用,或请求签名不匹配。核对 AK、环境、正文摘要和签名头。
429Throttled请求达到限额,按 Retry-After 返回的秒数等待,再以新 nonce 发起请求。
公共错误、重试与幂等说明 →