Skip to content

Authentication ​

SimVector map tiles use session-based authentication. Your server exchanges a long-lived API key for a JSON Web Token (JWT). The browser uses only the JWT.

The flow ​

text
Browser ──(1) request token──▶ Your server ──(2) GET /auth/jwt + API key──▶ SimVector
Browser ◀──(4) JWT───────────── Your server ◀──(3) JWT─────────────────────── SimVector
Browser ──(5) tile requests with Bearer JWT──────────────────────────────────▶ SimVector tiles
  1. The map client asks your server for a token.
  2. Your server calls the SimVector token endpoint using the API key.
  3. SimVector returns a JWT.
  4. Your server passes the JWT to the client.
  5. The client sends tile requests with Authorization: Bearer <JWT>.

Minting a token ​

http
GET https://api.simvector.net/v1/auth/jwt
x-api-key: {YOUR_API_KEY}

Call this only from server-side code. The key is also accepted as an api_key query parameter, but prefer the header: query strings tend to be written to access logs and proxies.

A successful response looks like this:

json
{
  "token": "eyJhbGciOiJSUzI1NiIs…",
  "grants": ["schedule_cloud"]
}

Tile access only needs token. See the Get a JWT reference for the full endpoint description.

Keep the API key secret

Never ship your API key in browser or mobile code, and never commit it to source control, including "example" env files and default values in config. Anyone holding it can mint tokens against your subscription. Store it in server configuration or a secrets manager.

About the token ​

PropertyValue
FormatJWT signed with RS256
Lifetime48 hours
IdentifiesYour community
Scopes tile access toThe tilesets in your subscription (currently globe and global_elevation_90m)
Public keysPublished as a JWKS at https://api.simvector.net/jwks

You normally treat the token as opaque. You do not need to decode or verify it; the tile service does that.

Caching and refreshing ​

Tokens last 48 hours, so there is no need to mint one per request or per visitor. A good pattern:

  • Server: cache the token for a few minutes (the Quick Start uses 5) and serve the cached value to all visitors. This keeps load on the token endpoint to a handful of calls per hour and stays well inside the 48-hour lifetime.
  • Client: let @simvector/maplibre-protocol hold the token for the life of the page. When a tile request returns 401, it calls your getToken again and retries that request once.

Only the token is worth caching on your server. Do not proxy or cache the tiles themselves: tiles are already served from our global edge network, and a copy of them goes stale when we update the data. See Request tiles directly.

Things to be aware of:

  • Refresh is reactive. The handler does not check expiry in advance; it reacts to a 401.
  • Only 401 triggers a retry. Other failures (including 403, 429 and 5xx) are thrown as errors with the message [SimVector] <status> <statusText> - <url> and are not retried automatically. Handle them with map.on('error', …) and, if you need it, your own backoff.
  • If your server caches tokens, keep the cache shorter than the token lifetime so a retry after 401 never receives an already-expired cached token.

Where to find your API key ​

Sign in to the SimVector Console, open your community, and go to Settings → General. The key is masked, with options to reveal and copy it. A paid Community Subscription is required.

Personal API keys are different

The Console's Settings → API Keys page manages personal keys. The community key on the community settings page is the one used for tile authentication.

Rotating your API key ​

Owners can regenerate the key from Settings → General. Regenerating immediately invalidates the previous key.

  1. Regenerate the key in the Console.
  2. Update the secret in your server configuration.
  3. Restart or redeploy so the new value is loaded.
  4. Clear any cached token if you want to be sure the next one comes from the new key. Existing tokens keep working until they expire.

If a key has been committed to a repository or shared by mistake, treat it as leaked: regenerate it, then remove it from the repository and its history.

Using plain HTTPS ​

If you are not using MapLibre, request tiles directly and set the header yourself:

bash
curl -H "Authorization: Bearer $SIMVECTOR_JWT" \
  "https://tiles.simvector.net/global_elevation_90m/0/0/0.png" -o tile.png

Troubleshooting ​

SymptomLikely cause
Token request fails with 401Wrong or regenerated API key.
Your token endpoint returns 502 or 503Upstream call failed, or the key is not configured in that environment. Check your server logs.
Tiles return 401 repeatedlyYour getToken is returning an empty or expired token. Make it throw on failure and check the token endpoint.
Tiles return another error statusThe handler throws [SimVector] <status> …. It does not retry; check the status and URL in the message.
Works locally but not in productionThe token endpoint is not reachable from the deployed client, or the key is not set in the production environment.

AMXM schema © 2024 RTCA, EUROCAE. Use does not imply endorsement by RTCA or EUROCAE.