Generieren von JWT -Token, um Anfragen an Apple zu stellenPython

Python-Programme
Anonymous
 Generieren von JWT -Token, um Anfragen an Apple zu stellen

Post by Anonymous »

Ich verwende den folgenden Code, um Apple eine Anfrage zu stellen. Dann stelle ich die folgende Curl -Anfrage, aber ich erhalte eine 401. Wie kann ich das lösen? < /P>
from datetime import datetime, timedelta
from time import time, mktime
import jwt

dt = datetime.now() + timedelta(minutes=19)

headers = {
"alg": "ES256",
"kid": "",
"typ": "JWT",
}

payload = {
"iss": "",
"iat": int(time()),
"exp": int(mktime(dt.timetuple())),
"aud": "appstoreconnect-v1",
}

with open("AuthKey.p8", "rb") as fh: # Add your file
signing_key = fh.read()

gen_jwt = jwt.encode(payload, signing_key, algorithm="ES256", headers=headers)

print(f"[JWT] {gen_jwt}")
< /code>
Konsole: < /p>
curl -v -X PUT "https://api.storekit.itunes.apple.com/i ... sumption//" \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"accountTenure": 2,
"appAccountToken": "",
"consumptionStatus": 3,
"customerConsented": true,
"deliveryStatus": 0,
"lifetimeDollarsPurchased": 1,
"lifetimeDollarsRefunded": 1,
"platform": 1,
"playTime": 6,
"refundPreference": 2,
"sampleContentProvided": true,
"userStatus": 1
}'
< /code>
Ich habe das JWT -Token validiert und es ist richtig. Ich habe den privaten Schlüssel erhalten, indem ich zu Benutzerzugriff - App Store Connect - Teamschlüssel

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post