Last active
June 22, 2020 22:56
-
-
Save calvinhp/6ef76c965bb860391f723d220be705be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import hashlib | |
import hmac | |
import json | |
import os | |
import time | |
import requests | |
api_endpoint = "https://api.scaleengine.net/stable/" | |
api_key = os.environ["SE_PUBLIC"] | |
secret = os.environ["SE_SECRET"] | |
cdn = os.environ["SE_CDN"] | |
def grab_data(): | |
payload = { | |
"command": "files.list", | |
"api_key": api_key, | |
"timestamp": int(time.time()), | |
"cdn": int(cdn), | |
"path": "sestore4/calvinhp", | |
} | |
signature = base64.b64encode(hmac.new(str.encode(secret), str.encode(json.dumps(payload, separators=(',', ':'))), digestmod=hashlib.sha256).digest()) | |
payload["signature"] = signature.decode('ascii') | |
response = requests.post(api_endpoint, json=payload) | |
print(response.text) | |
if __name__ == '__main__': | |
grab_data() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment