Created
May 18, 2022 15:12
-
-
Save tomcurran/d966c941c58baf494deeb4b6f4192b4e to your computer and use it in GitHub Desktop.
Create App Store Connect token for API requests from private key, issue ID, key ID
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
| require "base64" | |
| require "jwt" | |
| ISSUER_ID = "" | |
| KEY_ID = "" | |
| PRIVATE_KEY_FILE="" | |
| private_key = OpenSSL::PKey.read(File.read(PRIVATE_KEY_FILE)) | |
| token = JWT.encode( | |
| { | |
| iss: ISSUER_ID, | |
| exp: Time.now.to_i + 20 * 60, | |
| aud: "appstoreconnect-v1" | |
| }, | |
| private_key, | |
| "ES256", | |
| header_fields = { | |
| kid: KEY_ID | |
| } | |
| ) | |
| puts token |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment