Skip to navigation

Authentication

Sign every request with an API key or a JWT
View as Markdown

You can authenticate in two ways: an API key, or a JWT from the OAuth password grant. Pick one. Both go in the request headers, and the same credentials work on the OTA endpoint and on the schedule and ticket services.

API key

Send your key in the x-api-key header on every request.

curl -X POST https://api.sar.worldticket.cloud/ota/v2015b/OTA \
-H "x-api-key: YOUR_API_KEY" \
-H "local-name: OTA_ReadRQ" \
-H "Content-Type: application/json" \
-d '{ ... }'

Keep your key on the server. Never ship it in a browser or a mobile app, where anyone could read it and make requests as you.

JWT (OAuth password grant)

The identity provider is an OpenID Connect server with one realm per tenant. Ask it for a token with the password grant, then send the access token as a bearer token. You need five values from your onboarding:

VariableWhat it isExample
tenantYour realm, a short name for the operatorsar
client_idThe application IDsms4
client_secretThe application secret33357c21-3233-4eb3-a420-****
usernameYour user login
passwordYour user password

The token endpoint is /realms/{tenant}/protocol/openid-connect/token under the auth base URL.

curl -X POST https://api.sar.worldticket.cloud/auth/realms/YOUR_TENANT/protocol/openid-connect/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=password" \
-d "client_id=YOUR_CLIENT_ID" \
-d "client_secret=YOUR_CLIENT_SECRET" \
-d "username=YOUR_USERNAME" \
-d "password=YOUR_PASSWORD"

The response gives you an access token and a refresh token, with their lifetimes in seconds.

{
"access_token": "eyJhbGciOiJSU...",
"expires_in": 7200,
"refresh_expires_in": 14400,
"refresh_token": "eyJhbGciOiJ...",
"token_type": "bearer",
"id_token": "eyJhbGciOiJ...",
"not-before-policy": 1565113348,
"session_state": "89fde8f3-39ff-436e-9dce-99387c591fda"
}

Send the access token on each API call:

curl -X POST https://api.sar.worldticket.cloud/ota/v2015b/OTA \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "local-name: OTA_ReadRQ" \
-H "Content-Type: application/json" \
-d '{ ... }'

The access token lasts two hours and the refresh token four. Before the access token expires, trade the refresh token for a new pair at the same endpoint instead of sending the password again.

curl -X POST https://api.sar.worldticket.cloud/auth/realms/YOUR_TENANT/protocol/openid-connect/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=refresh_token" \
-d "client_id=YOUR_CLIENT_ID" \
-d "client_secret=YOUR_CLIENT_SECRET" \
-d "refresh_token=YOUR_REFRESH_TOKEN"

The test identity provider lives at https://test-auth.worldticket.net/auth, with the same realm path. For client setup, see the GO7 docs.