Post

Replies

Boosts

Views

Activity

Reply to I need the Python code for connecting to my Apple appstore sales reports
import requests, time, json from authlib.jose import jwt EXPIRATION_TIME = int(round(time.time() + (10.0 * 60.0))) # 20 minutes timestamp PATH_TO_KEY = "AuthKey_KEY_ID.p8" with open(PATH_TO_KEY, "r") as f: PRIVATE_KEY = f.read() header = {"alg": "ES256", "kid": KEY_ID, "typ": "JWT"} payload = { "iss": ISSUER_ID, "exp": EXPIRATION_TIME, "aud": "appstoreconnect-v1", "scope": ["GET /v1/salesReports"] } Create the JWT token = jwt.encode(header, payload, PRIVATE_KEY) print(token) API Request JWT = "Bearer " + token.decode() URL = "https://api.appstoreconnect.apple.com/v1/salesReports" HEAD = {"Authorization": JWT} params = { "filter[frequency]": "DAILY", "filter[reportDate]": "2023-09-01", "filter[reportSubType]": "DETAILED", "filter[vendorNumber]": "vendor_number", "filter[reportType]": "SUBSCRIBER", "filter[version]": "1_3" } r = requests.get(URL, params=params, headers=HEAD) print(r) hi @Appleturkiye @tommygod I am using this snippet to download sales reports, but I am receiving a status 401 error. Is there a mistake I made when trying to download the report? Any suggestions would be helpful.
Nov ’23