Hello, following the practices use on:
https://developer.apple.com/documentation/appstoreconnectapi/generating_tokens_for_api_requests
I used Python, and uses pyjwt and request library in attempt of making requests
I created my jwt header and payload like this
jwt_header = {
"alg": "ES256",
"kid": MY_KEY_ID,
"typ": "JWT"
}
jwt_payload = {
"iss": MY_ISSUER_NUMBER,
"iat": time_now,
"exp": time_10_min,
"aud": "appstoreconnect-v1"
}
and jwt can encode successfully without error
jwt_token = jwt.encode(jwt_payload, MY_SECRET_KEY, algorithm="ES256", headers= jwt_header)
but really when I try to make a get request with
get_app_id_endpoint = "https://api.appstoreconnect.apple.com/v1/apps"
headers = {
'Authorization': f'Bearer {jwt_token}',
'Content-Type': 'application/json'
}
response = requests.get(get_app_id_endpoint, headers=headers)
it always gets a 401 response. Is there anything that need to be changed here?
I have tried sosme of the solutions found online such as
take out "alg" field in jwt_header
take out "iat" field in jwt_payload
cast time_now and time_10_min (UNIX epoch time) to integer
take out Content-Type filed in headers
but issue remains, what could I possible do here to get over it?