AppleMapsServer.Token (apple_maps_server v0.2.0)

Copy Markdown View Source

Apple Maps Server token generation and exchange.

Apple's flow has two steps:

  1. Sign an ES256 JWT with your Maps private key (.p8), identifying the Maps key via the kid header and your Team ID via the iss claim.
  2. Exchange that JWT for a short-lived access token at GET /v1/token. That access token is what every subsequent API call must send as its Authorization: Bearer credential.

generate_jwt/1 does step 1; access_token/1 does both.

Summary

Functions

Sign a JWT and exchange it for an Apple Maps access token.

Like access_token/1 but also returns the unix-epoch expiry time, for cache use.

Build and sign the Apple Maps auth JWT (ES256).

Types

jwt()

@type jwt() :: String.t()

Functions

access_token(opts \\ [])

@spec access_token(keyword()) :: {:ok, String.t()} | {:error, term()}

Sign a JWT and exchange it for an Apple Maps access token.

access_token_with_expiry(opts \\ [])

@spec access_token_with_expiry(keyword()) ::
  {:ok, String.t(), integer()} | {:error, term()}

Like access_token/1 but also returns the unix-epoch expiry time, for cache use.

generate_jwt(opts \\ [])

@spec generate_jwt(keyword()) :: {:ok, jwt()} | {:error, term()}

Build and sign the Apple Maps auth JWT (ES256).