Skip to content

Instantly share code, notes, and snippets.

@tomcurran
Created May 18, 2022 15:12
Show Gist options
  • Select an option

  • Save tomcurran/d966c941c58baf494deeb4b6f4192b4e to your computer and use it in GitHub Desktop.

Select an option

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
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