Created
April 22, 2021 12:03
-
-
Save SilentKernel/a288f7b979fcb1b324a22c9137df49fd to your computer and use it in GitHub Desktop.
This file contains 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 '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