You will need the requests
and authlib
packages. Just run :
$ pip install requests authlib
Then you need to generate an API Key from the App Store Connect portal (https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api).
In the Python code below, replace the values of KEY_ID
, ISSUER_ID
and PATH_TO_KEY
with your own.
You can change the URL of the request you want to make with the URL
variable.
Finally, if you have some query parameters to pass in, use the params
parameter of requests.get()
(or requests.post()
).
Hi. I used this example early and it had worked fine, but today I faced with "Error 401". When I tried to use the same token in the curl, it has worked too. The solution is to change the expiration time to 19 min (thanks to my colleague Oleh for this solution)
EXPIRATION_TIME = int(round(time.time() + (19.0 * 60.0))) # 19 minutes timestamp
or just add small delay
time.sleep(5)
before request.