This script will generate a new client secret key and print the new key to the console, so you can copy and paste it into your Project using the "Sign in with Apple" feature.
Apple doesn't accept client secret JWTs with an expiration date more than six months after the creation date. That means you'll need to rotate your client secret, at minimum, every six months.
(Note: To be on a safer side, always rotate your client secret every five months instead).
- Python 3.6+
- Apple Developer Account
- A private key file obtained from Apple Developer Portal
- A client ID obtained from Apple Developer Portal
- A team ID obtained from Apple Developer Portal
- A key ID obtained from Apple Developer Portal
- Clone this repository
- Create a new environment file named
.env
and add the following variables:
client_id=your_client_id
team_id=your_team_id
filename=your_key_filename.p8
key_id=your_key_id
- Create a new virtual environment and activate it
- Create
python3 -m venv env
- Activate
source env/bin/activate
(Linux/MacOS)
- Create
- Run
pip install -r requirements.txt
to install the dependencies - Move your private key file to the root of the project
- Run
python generate_client_secret.py
to generate a new client secret key