Last active
May 2, 2024 01:21
-
-
Save janakamarasena/cb1ebb4abec8c903329cb25ecb6fe562 to your computer and use it in GitHub Desktop.
Sign In with Apple Client Secret Generator
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 "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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires ruby
Also requires ruby-jwt
sudo gem install jwtAdd the necessary details and run the file.
ruby secret_gen.rb