Authentication


Requirements

{info} A basic understanding of OAuth is required. You can read more at oauth.net

Before you start you will need a Client ID and Secret.

You will need to create an application first.

OAuth Authentication

Authentication to the api is handled using OAuth 2.0 via the Client Credentials grant type.

The URLs for the auth server are as follows:

Generating a Token

An OAuth token is generated using the client credentials grant flow.

An HTTP POST request needs to be sent to https://auth.tradesafe.co.za/oauth/token

The following fields need to be included in the request:

  • grant_type: client_credentials
  • client_id: YOUR_CLIENT_ID
  • client_secret: YOUR_CLIENT_SECRET

Upon successful response you will receive a JSON response with an access_token. You can then use the token for authorization with the API.

cURL Example

curl --request POST \
  --url 'https://auth.tradesafe.co.za/oauth/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data grant_type=client_credentials \
  --data client_id=YOUR_CLIENT_ID \
  --data client_secret=YOUR_CLIENT_SECRET

Response

Successful authentications return a JSON an access_token.

{
  "access_token":"MTQ...jI3",
  "token_type":"bearer",
  "expires_in":3600,
  "refresh_token":""
}