Skip to main content

Authentication

TST Connect supports authentication via the OAuth client credentials flow. You will have unique clientIds for development and production environments, and data returned is scoped to your configuration.

1. Exchange your credentials for a token​

curl -s -u $CLIENT_ID \
-d grant_type=client_credentials \
https://connect-dev.tstllc.net/oauth2/token

And then input your clientSecret. Your response should look like:

{
"access_token": "<jwt>",
"expires_in": 3600,
"token_type": "Bearer"
}

2. Call the API with the token​

curl https://connect-dev.tstllc.net/shop/v1/cruise/ping \
-H "Authorization: Bearer $ACCESS_TOKEN"

Token lifetime​

Tokens last one hour from when they are issued. There is no refresh token in this flow. You should check the exp claim on the JWT access token and request a new token prior to its expirey. For best results, reuse a token until it expires rather than fetching a new one per request. There is a small cache in front of the /oauth2/token endpoint to protect against malformed clients that do request a new token on every request, so trust the exp claim in the token over the expires_in returned in the response body.

Scopes​

Your client is provisioned with scopes named connect/<capability>, where the capability is the first path segment of the route — shop routes require connect/shop. You do not need to request scopes explicitly: omit the scope parameter and the token carries whatever your client is entitled to.

Try in the docs pages​

Our API references pages are configured so that you can log in and execute sample queries directly within the documentation site. Begin by selecting the server for the environment you are calling, open Authorize on any operation, paste your client ID and secret, and the reference fetches a token from that server's /oauth2/token and attaches it to the requests you send from the page.

When something is rejected​

  • 401 — no token, or one that is invalid or expired. Request a new token and retry.
  • 403 — the token is valid, but your client is not entitled to that route. Check the route's capability against the scopes you were issued, and contact TST if it should be included.
  • 400 — the request itself failed validation. See the error body; this is unrelated to authentication.

If the token endpoint returns invalid_client, the client ID or secret is wrong, or the credentials were sent to the wrong pool.