Created
June 23, 2018 22:06
-
-
Save zachomedia/a6e3f6f68091c6aa333da50d7b44a330 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on https://codegists.com/snippet/javascript/indexjs_aljs_javascript | |
// (found from https://forums.developer.apple.com/thread/103790) | |
// npm install jsonwebtoken | |
"use strict"; | |
const fs = require("fs"); | |
const jwt = require("jsonwebtoken"); | |
const privateKey = fs.readFileSync("AuthKey.p8").toString(); //your MusicKit private key | |
const jwtToken = jwt.sign({}, privateKey, { | |
algorithm: "ES256", | |
expiresIn: "180d", | |
issuer: "TEAM_ID", //your 10-character Team ID, obtained from your developer account | |
header: { | |
alg: "ES256", | |
kid: "MUSICKIT_KEY_ID" //your MusicKit Key ID | |
} | |
}); | |
console.log(jwtToken); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment