I've used JWTs a lot for user authentication, but I can't get them to work with MapKitJS. I have a route that creates a token...
const privateKey = fs.readFileSync(__dirname + "/../MapKitJS_AuthKey.p8");
const token = jwt.sign({
origin: event.local === true ? 'http://localhost:8080' : 'NO'
}, privateKey, {
header: {
kid: process.env.kid,
typ: 'JWT',
alg: 'ES256'
},
issuer: process.env.iss,
expiresIn: '1h',
algorithm: 'ES256'
});
I'm using node, and the resulting token looks just fine...
eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IkdBQUw3VlVWRzQifQ.eyJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjgwODAiLCJpYXQiOjE1NTE1MDkzNDgsImV4cCI6MTU1MTUxMjk0OCwiaXNzIjoiOEJVMlk4QzVKNyJ9.BSXts5IrsUyPfsPnkbI-MeUC3xpZkQ2K_1wsjMw-RrT3qLE7WSULFpmvF076V6HAU1J80vBCd5o8veRXCFWN4g
Looking at it in jwt.io it come out nicely...
{
"alg": "ES256",
"typ": "JWT",
"kid": "GAAL7VUVG4"
}
{
"origin": "http://localhost:8080",
"iat": 1551509348,
"exp": 1551512948,
"iss": "8BU2Y8C5J7"
}
But passing the toke to MapKitJS I always get "Bootstrap.init(): initialization failed because the authorization token is invalid." from the server. I'm at a loss. I have no idea what to do at this point.