Authentication

How to use JSON Web Tokens

The api-connector, object-storage/document, order-search/poll and shipment/poll integration API's support two means of authentication:

circle-exclamation

Basic Authentication upon every request

You can use the Basic HTTP Authentication scheme to authenticate upon every request.

circle-info

Pro: this is a simple authentication method, supported by all integrations

Con's:

  • The response time is long, average 1 second, up to 3 seconds.

  • It is only supported by api-connector, object-storage/document, order-search/poll and shipment/poll API's, not by other service API's.

circle-exclamation

How to Authenticate

You can authenticate using a Basic Authorization HTTP header with a base 64 encoded email and password:

When correctly authenticated, your request will be processed and if all is well, the response will have HTTP status code 200arrow-up-right OK

When NOT correctly authenticated, the response will return HTTP status code 401arrow-up-right Unauthorized

In case of some server issue, including the upstream authentication service being unreachable, the response will return HTTP status code 500arrow-up-right Internal Server Error

Basic Authentication with JSON Web Tokens

  1. Use the Basic HTTP Authentication scheme to authenticate against the authentication service.

  2. Use the returned JWT to authorize against the Tradecloud api-connector and other service API's for all subsequent requests.

circle-info

Pro's:

  • Faster response time (except for the initial authentication), average 200ms

  • It is supported by all connector and service API's

Con: this is a more complex authentication and authorization method

circle-exclamation

Authenticate

You can log in using a Basic Authorization HTTP header with a base 64 encoded email and password:

When correctly authenticated, the response will return HTTP status code 200arrow-up-right OK and contain access and refresh tokens:

When NOT correctly authenticated, the response will return HTTP status code 401arrow-up-right Unauthorized

Authorize

Use a Bearer Authorization HTTP header with the access token in each request:

When correctly authenticated, your request will be processed and if all is well, the response will have HTTP status code 200arrow-up-right OK

Refreshing the token

An access token will expire after 1 hour and a refresh token after 24 hours. When your access token has expired you have to use the refresh token. If your refresh token expires you have to log in again.

You can refresh your access token by placing an HTTP request to /authentication/refresh, using only the Refresh-Token header. Do NOT use the Authorization header.

When the refresh token is valid, the API will return HTTP status code 200 OK and containing a new access token and a new refresh token. Otherwise, the API will return HTTP status code 401 Unauthorized

The refresh token cannot be used once it is expired or a new refresh token is generated.

Log out

Log out will invalidate the refresh token immediately. The access token will expire after 10 minutes.

You can invalidate your refresh token by placing an HTTP request to /authentication/logout, using only the Refresh-Token header. Do NOT use the Authorization header.

Last updated