Created
June 17, 2024 11:05
-
-
Save emndeniz/81d6a9df19d3627b6cd7457e45130872 to your computer and use it in GitHub Desktop.
JWTTokenGeneratorForAppStoreConnect.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jwt | |
import time | |
def generate_token(key_id, issuer_id, private_key_path): | |
with open(private_key_path, 'r') as key_file: | |
private_key = key_file.read() | |
headers = { | |
"alg": "ES256", | |
"kid": key_id | |
} | |
payload = { | |
"iss": issuer_id, | |
"exp": int(time.time()) + 20 * 60, | |
"aud": "appstoreconnect-v1" | |
} | |
token = jwt.encode(payload, private_key, algorithm="ES256", headers=headers) | |
return token | |
key_id = 'YOUR_KEY_ID' # Use your Key ID you get from App Store Connect | |
issuer_id = 'YOUR_ISSUER_ID' # Use your Issuer ID you get from App Store Connect | |
private_key_path = 'path/to/AuthKey.p8' # The path of your AutKey you have donwloaded from App Store Connect | |
token = generate_token(key_id, issuer_id, private_key_path) | |
print(token) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment