A NodeJS script that generates client_secret for Apple Sign in
This repo could start in a Docker container, but before you start to build the image you have to create a folder named secrets
which must contains two files
File name | Description |
---|---|
.env | The env file that contains the Apple Developer Account info |
private.key | The private key of the project (see the Apple guide) |
The .env
file must contain those vars
Var name | Description |
---|---|
teamId |
Apple Team ID |
clientId |
Bundle name |
keyId |
Private key ID |
Example of .env
teamId=123456789A
clientId=com.mycompany.app
keyId=ZQ12345678
Once you have done all the above steps you can procede to build the image from the Dockerfile running
$ docker build . --tag solutiontech/apple-client-secret-generator
Then run the image interactively
$ docker run -it solutiontech/apple-client-secret-generator
The output in the console look something like this
key eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsI...
validity 180 days
Save the key and enjoy! The validity is set to 180 days accordingly with the max expiration time in the Apple documentation
Below a simple guide to find and retrieve the informations that you need to make the script work
By going to Keys create a new Sign in with Apple
key being sure of select the right Primary App ID
in the key configuration (see Client ID]
once done hit the Register
button, wait until done after you will be asked to download the key it is a one time download so make sure of download the key and save it in a secure place otherwise you have to recreate it by revoking the existing one
In order to make the file suitable for this script you have to rename the key from AuthKey_A123456789.p8
to private.key
also write down the Key ID
for the .env
(it is either in the file name preceded by _
or in the download page as the screenshot above)
The Apple Team ID could be found either in the Membership Details of your Apple Developer account
or in the top right corner by going in the Certificates Manager
The Client ID it is nothing else than the budle name of the app, you could retrive it from the Xcode project or from the Identifiers section. Make sure that it the same bundle name that you selected for the key