Skip to content

Instantly share code, notes, and snippets.

@emndeniz
Created June 17, 2024 11:05
Show Gist options
  • Save emndeniz/81d6a9df19d3627b6cd7457e45130872 to your computer and use it in GitHub Desktop.
Save emndeniz/81d6a9df19d3627b6cd7457e45130872 to your computer and use it in GitHub Desktop.
JWTTokenGeneratorForAppStoreConnect.py
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