Trying to get Spark's helpMenu post request to work but I think I have the wrong shared secret and engineering is already off for the weekend.
This commit is contained in:
59
Scripts/Walmart/Spark/help_menu.py
Normal file
59
Scripts/Walmart/Spark/help_menu.py
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import requests
|
||||||
|
import hashlib
|
||||||
|
import hmac
|
||||||
|
import json
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
secret_key = b'IU9BRsR7WTDWdDooX4w9DFLqweAZreLwaDDaLnVRkHZeubcSdA'
|
||||||
|
prod_url = "https://walmart.northpass.io/helpMenu"
|
||||||
|
driver_auth = "https://walmart.northpass.io/driver/authenticate"
|
||||||
|
stage_url = "https://walmart.np-mt-dev.net/helpMenu"
|
||||||
|
random_uuid = uuid.uuid4()
|
||||||
|
|
||||||
|
msg_body = {
|
||||||
|
"messageExpirationTimestamp": 14357000,
|
||||||
|
"driver": {
|
||||||
|
"uuid": str(random_uuid),
|
||||||
|
"accessLevel": "BEGINNER"
|
||||||
|
},
|
||||||
|
"subCategory": "REWARDS",
|
||||||
|
"appContext": "contextAwareHelp"
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_body_json = json.dumps(msg_body, separators=(',', ':'), sort_keys=True)
|
||||||
|
body_signature = hmac.new(secret_key, msg_body_json.encode('utf-8'), hashlib.sha256).hexdigest()
|
||||||
|
|
||||||
|
# "accept": "application/json",
|
||||||
|
# "X-Api-Key": "6hUfJdAartHTHhHc0WIRZYPWe",
|
||||||
|
# header = {
|
||||||
|
# "X-Hmac-SHA256": '7731606cf88856a56450b0a767cddea002db97685646578caeac20ab09ffdab0'
|
||||||
|
# }
|
||||||
|
|
||||||
|
# canonical_headers = '\n'.join(f'{k.lower()}:{v.strip()}' for k, v in sorted(headers.items()))
|
||||||
|
# header_signature = hmac.new(secret_key, canonical_headers.encode('utf-8'), hashlib.sha256).hexdigest()
|
||||||
|
headers = { 'Content-Type': 'application/json','X-Hmac-SHA256': body_signature }
|
||||||
|
|
||||||
|
# prod = requests.post(driver_auth, headers=headers)
|
||||||
|
prod = requests.post(prod_url, headers=headers, json=msg_body)
|
||||||
|
print(f"Status Code: {prod.status_code}")
|
||||||
|
print(f"Response: {prod.json()}")
|
||||||
|
print(f"Body Signature: {body_signature}")
|
||||||
|
# print(f"Header Signature: {header_signature}")
|
||||||
|
|
||||||
|
"""
|
||||||
|
This is a valid curl request for nTransit:
|
||||||
|
|
||||||
|
curl -X POST --location "https://ntransit.northpass.io/driver/authenticate" \
|
||||||
|
-H "X-Hmac-SHA256: SECRET" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"sessionExpiryTimeInSeconds": 3600,
|
||||||
|
"messageExpirationTimestamp": 1758722640,
|
||||||
|
"driver": {
|
||||||
|
"uuid": "3949c78e-9a9c-43d6-92f0-8c474c0e1d1e",
|
||||||
|
"zone": "Zone 1"
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
Reference in New Issue
Block a user