Skip to content

Authorisation v2

Lee Sambridge edited this page May 29, 2024 · 11 revisions

Authorization

In order to use the Endurance Zone API your application will need a valid API key to create a Bearer Token, which can then be used for all Api Calls. For security reasons different keys are required for different environments.

The API key should be used in calls to GetAuthToken to the API by providing it in the ApiKey header.

Endpoints will return a 401 status code if the API Key provided is missing, invalid or expired.

NOTE: Bearer tokens have a life span of 5 minutes before they expire and a new one needs generating.</mark>

See below for an example of an API key being used

Curl

curl --location 'https://api.test.myezrewards.com/v2/GetAuthToken' \
--header 'apikey: ••••••' \
--data ''

HTTP

GET /v2/GetAuthToken HTTP/1.1
Host: api.test.myezrewards.com
apikey: ••••••

The response that is returned from the GetAuthToken Api, will be as follows:-

{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJQYXJ0bmVySWQiOiI5NDAyOTMiLCJQYXJ0bmVyTmFtZSI6IlZpcmdpbiBBY3RpdmUiLCJleHAiOjE3MTY5NzcxNTYsImlzcyI6IlRlc3QuY29tIiwiYXVkIjoiVGVzdC5jb20ifQ.NIkNmBnIJzPq--hTCfSXosg9yz9vVoDw4FKBNNiKXvY"
}

Use this token in proceeding Api calls such as

Curl (Bearer)

curl --location 'https://api.test.myezrewards.com/v2/members?emailAddress={{emailAddress}}' \
--header 'Authorization: Bearer {{token}}' \
--data ''

HTTP (Bearer)

GET /v2/members?EmailAddress={{emailAddress}} HTTP/1.1
Host: api.test.myezrewards.com
Authorization: Bearer {{token}}

Clone this wiki locally