A python script that generates a JWT token for the new MapKit JS web API from Apple. The token generated is valid for 180 days.
In order to run the script this packages must be installed on your system:
You can check it with pip list
command on your Terminal. If not presented install it with
sudo pip install pyjwt --user
sudo pip install cryptography --user
In order to generate a valid JWS token you must provide 3 fields and an optional, but recommended, one. The mandatory fields are...
- Private Key file. The file with .p8 extension downloaded from Apple developer website.
- Your Apple Team ID. Available in your developer profile.
- MapKit Api Key ID.
The optional is a domain restriction.
- Origin. URL where your mapkit web is hosted. If yoor website is under a subdomain you must include it.
# Mandatory fileds.
private_key_file_path = "[YOUR_PRIVATE_KEY_FILE].p8"
apple_team_id = "YOUR_APPLE_TEAM_ID"
mapkit_key_id = "YOUR_MAPKIT_KEY_ID"
# Optional but recommended fields.
origin_domain = "http://subdomain.yourdomain.com"
Open Terminal app on your macOS or Command Prompt on Windows and type the follwing command
python mapkitjs_token_generator.py
A couple of seconds later you will see something like this
-
Getting and Using a Mapkit JS Key. WDC 2018 session
-
Introducing MapKit JS. WWDC 2018 session
-
JWT Protocol. Website with libraries and a token sandbox
Any question or suggestion? You will find me on twitter at @fitomad