API Token Generation
Generation of token for the first time and dynamic generation.
GET /api/v2/accesstoken/generate{?name}
MUST be called to generate API token for the first time. Requires a physical button press on the gateway. A time window of 2 minutes starts upon button press to allow time for token to be generated. Once generated, the time window clears and if more tokens is desired to be created, POST /api/v2/accesstoken/generate
can be called with token in Authorization
header or the gateway button can be pressed again.
Query Parameters
Name | Description | Type |
---|---|---|
name | Optional name to assign to generated access token. Default: "default" | String |
Responses
201 Created
Called within time window after button press and successfully generated and returned access token.
Example Response
{
"status": 201,
"returnCode": 2,
"token": {
"name": "default",
"token": "2f1f4339c7b77fa3474bf8ba8852349273e928bb8ad9d186",
"creation_date": "2016-12-24T08:04:34",
"last_used": null,
"ip_address": null
}
}
Response Details (JSON)
Property | Description | Type |
---|---|---|
status | Mirrors the HTTP status code of response. | Integer |
token | Actual token that should be passed in through Authentication header.Should be a 48 character randomly generated hexadecimal string. | String |
creation_date | Date and time token was created. | Datetime (string) |
last_used | Date and time token was last used. If it was just created or hasn't been used in a request, last_used will be null. | Datetime (string) | null |
ip_address | IP address of client which made the last call. Null if token hasn't been used in a request. | Datetime (string) | null |
403 Forbidden
Generation of access token refused as time window has expired or gateway button was not pressed.
{
"status": 403,
"message": "Time window expired or gateway button not pressed.",
"returnCode": -3
}
400 Bad Request
Usually indicates that the optional name
is provided but invalid.
{
"status": 400,
"message": "Invalid name for access token. Can only contain letters, numbers, hyphens, and underscores.",
"returnCode": -4
}
Updated less than a minute ago