jsp-open-api-signature/examples/sign_only.py
Simple.C.Han 13c7f62870 init
2026-06-17 10:23:52 +08:00

31 lines
702 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from pathlib import Path
import sys
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from openx_sdk import OpenXSigner
# 只演示签名生成,不依赖 requests也不会发送网络请求。
signer = OpenXSigner(
access_key="",
secret_key="",
)
# 固定 timestamp 和 nonce 时,输出应与 curl 示例中的 signature 完全一致。
signed = signer.sign(
query={
"comId": "100787681",
"accountId": "861533101421002919",
"startDate": "2025-07-01",
"endDate": "2025-07-30",
"pageNum": "1",
"pageSize": "20"
},
timestamp="1780889319",
nonce="9fb5235a-175c-4d24-adde-aca39ad1e7bc",
)
print(signed.signature)
print(signed.headers)