Skip to content

Instantly share code, notes, and snippets.

@mknepprath
Forked from leemartin/musickit-token-encoder.js
Created February 20, 2021 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mknepprath/c5582c8bbb3f11789b56b1eb8ab7564c to your computer and use it in GitHub Desktop.
Save mknepprath/c5582c8bbb3f11789b56b1eb8ab7564c to your computer and use it in GitHub Desktop.
Apple Music API Token for MusicKit
"use strict";
const fs = require("fs");
const jwt = require("jsonwebtoken");
const privateKey = fs.readFileSync("AuthKey.p8").toString();
const teamId = "ABCDE12345";
const keyId = "ABCDE12345";
const jwtToken = jwt.sign({}, privateKey, {
algorithm: "ES256",
expiresIn: "180d",
issuer: teamId,
header: {
alg: "ES256",
kid: keyId
}
});
console.log(jwtToken);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment