Apple Maps Server API invalid JWT token

Hello,

I'm truing to use Maps Server API. I have:

  1. Created Maps Identifier and a Private Key
  2. Used token maker to create a JWT token. I also tried creating JWT token manually.
  3. After generating a JWT token I used Maps Server API Playground with my JWT and I can successfully use Maps Server API.

The problem is that when I try to use my JWT in either JS code, Postman or curl request, I get "Invalid Token" error. Which is very strange, because I doubled checked everything dozen of times and JWT works in Apple's playground tool.

Here's a request example:

curl -si -H"Authorization: Bearer <jwt token>" "https://maps-api.apple.com/v1/geocode?q=Apple%20Park%2C%20Cupertino%2C%20CA"
  1. My token is valid for 1 year
  2. When generating JWT token I left "Domain restriction" field empty.
Answered by Apple Staff in 790179022

In order to call Apple Maps Server APIs directly (e.g., using curl), you need to use a Maps Access Token. You can generate this token by following the documentation.

Once you have generated the Maps Access Token, you can use it to call Apple Maps Server APIs as described in the API documentation. eg Geocode an address

Example:

  • Generate a Maps Access Token using your maps_auth_token (which is the jwt token you generated):
curl -si -H "Authorization: Bearer <maps_auth_token>" "https://maps-api.apple.com/v1/token"
  • Call Apple Maps Server API:
curl -si -H "Authorization: Bearer <maps_access_token>" "https://maps-api.apple.com/v1/geocode?q=Apple%20Park%2C%20Cupertino%2C%20CA"

Please note that the Maps Access Token is valid for 30 minutes.

For additional troubleshooting regarding invalid tokens, please refer to the Debugging an Invalid token guide.

In order to call Apple Maps Server APIs directly (e.g., using curl), you need to use a Maps Access Token. You can generate this token by following the documentation.

Once you have generated the Maps Access Token, you can use it to call Apple Maps Server APIs as described in the API documentation. eg Geocode an address

Example:

  • Generate a Maps Access Token using your maps_auth_token (which is the jwt token you generated):
curl -si -H "Authorization: Bearer <maps_auth_token>" "https://maps-api.apple.com/v1/token"
  • Call Apple Maps Server API:
curl -si -H "Authorization: Bearer <maps_access_token>" "https://maps-api.apple.com/v1/geocode?q=Apple%20Park%2C%20Cupertino%2C%20CA"

Please note that the Maps Access Token is valid for 30 minutes.

For additional troubleshooting regarding invalid tokens, please refer to the Debugging an Invalid token guide.

Apple Maps Server API invalid JWT token
 
 
Q