确保您的Apple企业账户已购买了电影捆绑包,如果还是无法获取到数据,可以尝试重新注册和生成凭证。以下是Python示例代码:
import jwt
import requests
import time
# Replace with your values
jwt_key_id = ""
team_id = ""
app_bundle_id = ""
private_key_path = ""
# URL to obtain a token from
jwt_token_url = "https://appleid.apple.com/auth/token"
# Time the JWT is generated
time_now = int(time.time())
# JWT header
jwt_headers = {
"alg": "ES256",
"kid": jwt_key_id,
"typ": "JWT"
}
# JWT Payload
jwt_payload = {
"iss": team_id,
"iat": time_now,
"exp": time_now + 86400 * 180,
"aud": "https://appleid.apple.com",
"sub": app_bundle_id,
}
# Load Private Key and sign JWT
with open(private_key_path, "r") as private_key_file:
private_key = private_key_file.read()
jwt_token = jwt.encode(jwt_payload, private_key, algorithm="ES256", headers=jwt_headers)
# Request Access Token from Apple's Authentication Server
r = requests.post(
jwt_token_url,
data={
"client_id": team_id,
"client_secret": jwt_token,
"grant_type": "client_credentials",
},
)
token_data = r.json()
# The actual request to the API
response = requests.get(
"https://api.appstoreconnect.apple.com/v1/apps/{}/appStoreVersionRelationships".format(app_bundle_id),
params={
"include": "bundle,merchandisedVersions,app",
},
headers={
"Authorization": "Bearer {}".format(token_data["access_token"])
},
)
print(response.json())