A simple command line program amdevtok to generate Apple Music Developer Token. Based on JWT C Library by Ben Collins.
- https://github.com/akheron/jansson
- OpenSSL or GnuTLS
- cmake
- autoconf
- autoreconf
- automake
- libtool
- jansson
- jansson-devel
- openssl
- openssl-devel
- check
- check-devel
- patch
- Apply amdevtok patch
- patch -p1 < ./amdevtok.diff
- Compile libjwt
- 2.1 With GNU Make: Use
autoreconf -i
to create project files - 2.2
./configure
. - 2.3
make all
: build library.
Because amdevtok add non-standard function to the original libjwt source, it is staticly linked to libjwt object files, so there is no need to make install to install libjwt libraries into system.
- Compile amdevtok
sh make-amdevtok
This will compile amdevtok binary and create a symbol link amdevtokd, please note the trailing 'd'.
amdevtok will just print result, amdevtokd will also print the original payload.
amdevtok is static linked and can be copied anywhere has openssl/GnuTLS and jansson support. Usage is very straightfoward.
- Have your private key(.p8 file), kid and team id ready;
- execute amdevtok;
- Copy the results and go.
Usage: amdevtok private_key kid teamid [exp-length-in-seconds]
By default, expiration is plus 90 days:
./amdevtok /path/to/my.p8 ABC123DEFG DEF123GHIJ
Add 4th optional parameter to specify expiration period, eg. Expire in 1 hour:
./amdevtok /path/to/my.p8 ABC123DEFG DEF123GHIJ 3600
To print decoded payload as long as encoded message, use `amdevtokd` instead of `amdevtok`:
./amdevtokd /path/to/my.p8 ABC123DEFG DEF123GHIJ
Example output:
#./amdevtokd ./AuthKey_ABC123DEFG.p8 ABC123DEFG DEF123GHIJ
{
"alg": "ES256",
"kid": "ABC123DEFG"
}
{
"exp": 1527368388,
"iat": 1519592388,
"iss": "DEF123GHIJ"
}
ewogICAgImFsasdfasdfasdfCAia2lkIjogasdfasdfiCn0K.CnsKICAgICJleHAiOasdfasdfasdfImlhdCI6IDE1MTfasdfasdfXNzIjogIkRFRjEyasdfaISUoiCn0K.61234124asdfffCU0KWgc0vmOPgENzb3sasdfasdfnfasdfzCl1IohAA