我的Python代码中的API身份验证遇到问题

时间:2020-03-31 17:58:12

标签: python api hash request

我正在尝试发出请求HTTP标头以验证API请求。标头的要求是:

  1. iat =当前的unix时间戳
  2. api_identifier = api标识符
  3. api_uri = api uri被击中
  4. body_hash =(API HTTP请求的正文)sha256哈希(十六进制字符串)

我的问题是正文哈希要求不正确。因此,发出请求时我被拒绝访问。

下面是包含此有效负载的代码段:

 timestamp = int(round(time.time() * 1000))

 appKey = '5KdxA323VvmBn4Zq9pon7kL3J0hgntD64v'

 body = hashlib.sha256(('').encode('utf-8')).hexdigest()

 payload = {
   "iat":timestamp,
   "api_identifier": appKey,
   "api_uri": url,
   "body_hash": body
 }

0 个答案:

没有答案
相关问题