https://docs.github.com/en/developers/apps/authenticating-with-github-apps
pip install pyjwt
pip install cryptography
pip install pycryptodomeCreate the token from installation ID
import jwt
import calendar
import time
secret_key = """
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAA.......
-----END RSA PRIVATE KEY-----
"""
app_id = 18984
token = jwt.encode({
'iat': calendar.timegm(time.gmtime()) - 60,
'exp': calendar.timegm(time.gmtime()) + 600,
'iss': app_id
}, secret_key, algorithm='RS256').decode('utf-8')
print(token)
print("""
curl -i -X POST \
-H "Authorization: Bearer {}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/app/installations/:installation_id/access_tokens
""".format(token))