Spaces:
Running
Running
Update bearer_token.py
Browse files- bearer_token.py +2 -2
bearer_token.py
CHANGED
@@ -20,7 +20,7 @@ class BearerTokenGenerator:
|
|
20 |
secret_key = bytes(ast.literal_eval(secret_key_str))
|
21 |
|
22 |
timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
23 |
-
prefix = f"POST:{path}:{timestamp}
|
24 |
to_sign = prefix + body.encode()
|
25 |
|
26 |
signature = BearerTokenGenerator.generate_signature(to_sign, secret_key)
|
@@ -32,4 +32,4 @@ class BearerTokenGenerator:
|
|
32 |
@staticmethod
|
33 |
def generate_signature(to_sign: bytes, secret_key: bytes) -> str:
|
34 |
h = hmac.new(secret_key, to_sign, hashlib.sha256)
|
35 |
-
return base64.b64encode(h.digest()).decode()
|
|
|
20 |
secret_key = bytes(ast.literal_eval(secret_key_str))
|
21 |
|
22 |
timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
23 |
+
prefix = f"POST:{path}:{timestamp}".encode() # 移除换行符
|
24 |
to_sign = prefix + body.encode()
|
25 |
|
26 |
signature = BearerTokenGenerator.generate_signature(to_sign, secret_key)
|
|
|
32 |
@staticmethod
|
33 |
def generate_signature(to_sign: bytes, secret_key: bytes) -> str:
|
34 |
h = hmac.new(secret_key, to_sign, hashlib.sha256)
|
35 |
+
return base64.b64encode(h.digest()).decode()
|