Apple Music Keyman
A small utility that gets Apple Music API keys for you. It even allows getting user tokens, which are a bit more annoying since they involve a whole OAuth flow.
This tool is rudimentary and a work in progress.
How Apple Music authorization works
You need a couple of things:
- Apple Developer subscription. Yes, a paid one
- A certificate generated with access to Apple Music & MusicKit APIs.
- A Key ID for that certificate.
- A Team ID for your developer account
Using the team ID, private key file (.p8) and key ID, you build a JWT that becomes your developer token. This token alone allows access to AM resources that aren't related to a user.
With that developer token, you can initiate an OAuth flow to get a user token. This one allows you to access the listening history for your account, for example.
Using Keyman (uvx)
A convenient option is to use uvx to run the tool, without installing it:
# Set up the tool
uvx am-keyman configure TEAM_ID_HERE KEY_ID_HERE KEY_FILE_PATH
# Run the entire flow (dev token, user token)
uvx am-keyman get-tokens
Using Keyman (pip)
The CLI utility is published on PyPI:
pip install am-keyman
am-keyman
Using Keyman (local development)
uv sync
uv build
# Set up the tool
uv run am-keyman configure TEAM_ID_HERE KEY_ID_HERE KEY_FILE_PATH
# Run the entire flow (dev token, user token)
uv run am-keyman get-tokens
# OPTIONAL: Get your developer token
uv run am-keyman get-dev-token
# OPTIONAL: Grab a user token for yourself
uv run am-keyman get-user-token DEV_TOKEN_HERE
# ... a web server will open up, follow the instructions
# ... after completion, the token will show up in the console
Important note
If you mean to grab a user token using the command-line utility, do not use Firefox.
The stricter security settings built into the browser will break the OAuth flow and it won't work.
Safari worked great for me.
Release files for am-keyman 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| am_keyman-0.1.6.tar.gz | 4.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| am_keyman-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.9 kB
Release files / am_keyman-0.1.6.tar.gz
| Download URL | am_keyman-0.1.6.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cff532a87e29259b5c77dddc0e710a94d0a7a11c914f5afb28c9aaa697549373
|
|
BLAKE2b-256 checksum How to use checksums |
33d637a5760d5b1d48cc604df41ec30b866d910560f7f10fcc8c1d1f7e398772
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.3
|
Release files / am_keyman-0.1.6-py3-none-any.whl
| Download URL | am_keyman-0.1.6-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
783e17ab60d3909893a6632a43cf9d4f662be26198d2d4396e9054ba637076c9
|
|
BLAKE2b-256 checksum How to use checksums |
6bba418700e956d732a8097bf51e0efe2589ce41ac0b7d049d5cb9815f7da1c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.3
|