Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created January 17, 2019 15:11
Show Gist options
  • Save azamsharp/e4b4dbd350571233412331f4c5b8c66a to your computer and use it in GitHub Desktop.
Save azamsharp/e4b4dbd350571233412331f4c5b8c66a to your computer and use it in GitHub Desktop.
app.get('/services/jwt',(req,res) => {
const header = {
"alg": "ES256",
"typ": "JWT",
"kid": "yourmapidkey"
}
const payload = {
"iss": "yourteamid",
"iat": Date.now() / 1000,
"exp": (Date.now() / 1000) + 15778800,
}
var cert = fs.readFileSync('./private.p8'); // the private key you downloaded from Apple Developer Website
var token = jwt.sign(payload,cert, { header: header } );
res.json({token: token})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment