MapKit JS - previously working token invalid

I set up a second MapKit JS ID and key last night, and now my existing application is throwing "initialization failed because the authorization token is invalid."


The token has not changed (it is a long-lived, non-expired token). Additionally, creating a new token with the new key results in the same error.


I have double and triple checked the claims. Is anyone else having this problem?

Replies

Are there any other messages in the console? MKJS 5.31.2 includes client side logging for token errors that can be detected client-side.


Some things to check, for troubleshooting. Reasons why a token might be invalid include:


- The token is missing required fields.

- The token has all required fields, but some values are incorrect.

- The string provided for the origin claim in your token does not exactly match the Origin header passed by the browser. This string must match exactly, including protocol (http, https), trailing slashes, etc.

- The token contains duplicate headers. You can check for duplicate headers by decoding the token at the command line. For example:

echo "your-token-here" | tr "." "\n" | head -2 | base64 -D

- The token was issued more than a year ago.

- Your Apple Developer team has exceeded the number of requests allowed.

This issue resolved itself on 11/22/2019. I think there was a server-side bug that has since been fixed.

I've had this issue occur a couple of times, where a previously working JWT stops working without any other changes in the environment.

I was able to resolve this by removing and re-adding the MapKit JS service from the key from your apple developer account.

This resolved this issue immediately without having to replace the key or recreate the JWT you use for MapKit JS.