Skip to content

Instantly share code, notes, and snippets.

@SilentKernel
Created April 22, 2021 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SilentKernel/a288f7b979fcb1b324a22c9137df49fd to your computer and use it in GitHub Desktop.
Save SilentKernel/a288f7b979fcb1b324a22c9137df49fd to your computer and use it in GitHub Desktop.
require 'jwt'
key_file = 'key.txt'
team_id = ''
client_id = ''
key_id = ''
ecdsa_key = OpenSSL::PKey::EC.new IO.read key_file
headers = {
'kid' => key_id
}
claims = {
'iss' => team_id,
'iat' => Time.now.to_i,
'exp' => Time.now.to_i + 86400*180,
'aud' => 'https://appleid.apple.com',
'sub' => client_id,
}
token = JWT.encode claims, ecdsa_key, 'ES256', headers
puts token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment