Skip to content

Instantly share code, notes, and snippets.

@flub
Created April 28, 2022 16:09
Show Gist options
  • Save flub/4f36eab5f9075c790f951a6b0e5c3a67 to your computer and use it in GitHub Desktop.
Save flub/4f36eab5f9075c790f951a6b0e5c3a67 to your computer and use it in GitHub Desktop.
Script to test App Store Connect credentials as they are used by sentry.
"""Test credentials.
Instructions:
- Paste in the KEY_ID, KEY, and ISSUER_ID.
- Install dependencies: ``pip install requests pyjwt[crypto]``
- Run: ``python get_apps_test.py``
"""
import http.client
import logging
import time
from pprint import pprint
import jwt
import requests
KEY_ID = ""
KEY = """
-----BEGIN PRIVATE KEY-----
-----END PRIVATE KEY-----
"""
ISSUER_ID = ""
def main():
logging.basicConfig(level=logging.DEBUG)
http.client.HTTPConnection.debuglevel = 1
token = jwt.encode(
{
"iss": ISSUER_ID,
"exp": int(time.time()) + 60,
"aud": "appstoreconnect-v1",
},
KEY,
algorithm="ES256",
headers={"kid": KEY_ID, "alg": "ES256", "typ": "JWT"},
)
response = requests.get(
"https://api.appstoreconnect.apple.com/v1/apps",
headers={'Authorization': f'Bearer {token}'},
)
pprint(response.json())
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment