Created
March 19, 2022 12:57
-
-
Save chespinoza/9ae07e94647ea6e088e3f3000a9d8bc8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
from nozzle.spapi.client import MARKETPLACES, REGIONS, create_sigv4_session | |
NA_AUTH_URI = "https://api.amazon.com/auth/o2/token" | |
EU_AUTH_URI = "https://api.amazon.co.uk/auth/o2/token" | |
FE_AUTH_URI = "https://api.amazon.co.jp/auth/o2/token" | |
REGION = "NA" | |
ACCESS_KEY = "" | |
SECRET_KEY = "" | |
if __name__ == "__main__": | |
access_token = "" | |
sp_api_region = REGIONS["NA"].aws_region | |
session = create_sigv4_session( | |
access_key=ACCESS_KEY, secret_key=SECRET_KEY, spapi_region=sp_api_region | |
) | |
params = { | |
"restrictedResources": [ | |
{ | |
"method": "GET", | |
#"path": "/orders/v0/orders/123-1234567-1234567", | |
"path": "reports/2021-06-30/reports", | |
"dataElements": ["buyerInfo", "shippingAddress"], | |
} | |
], | |
"targetApplication": "XXX", | |
} | |
response = session.request( | |
"GET", | |
"https://sellingpartnerapi-na.amazon.com/tokens/2021-03-01/restrictedDataToken", | |
headers={ | |
"x-amz-access-token": access_token, | |
}, | |
json=params, | |
) | |
print(response.headers) | |
print(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment