-
-
Save kdisneur/58d5459c1bad998f5c53120171bd8af6 to your computer and use it in GitHub Desktop.
Sign In with Apple Client Secret Generator
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 = "Path to the private key" | |
team_id = "Your Team ID" | |
client_id = "The Service ID of the service you created" | |
key_id = "The Key ID of the private key" | |
validity_period = 180 # In days. Max 180 (6 months) according to Apple docs. | |
private_key = OpenSSL::PKey::EC.new IO.read key_file | |
token = JWT.encode( | |
{ | |
iss: team_id, | |
iat: Time.now.to_i, | |
exp: Time.now.to_i + 86400 * validity_period, | |
aud: "https://appleid.apple.com", | |
sub: client_id | |
}, | |
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