An object representing an authentication token.
An authentication token can be passed as the auth parameter in the Context parameters instead of the traditional token retreived from Admin.login to grant a user administrator rights in a webshop.
INFO
There are minor restrictions on the administrator rights granted by a token from this API and that is that they will NOT give access to this API. To gain access you will need to use Admin.login.
Property | Type | Description |
---|---|---|
uid | string | The authentication token. |
name | string | The name of the authentication token. |
description | string | A description of the token. May contain, e.g., information about who has it and what it is used for. |
active | boolean | Whether this authentication token can be used. |
created | string | Date and time of when the authentication token was created. |
lastUsed | string | Date and time of when the authentication token was last used. |
Takes a filter object and returns the number of authentication tokens found, as an integer.
A filter object specifying which authentication tokens to count. See Filter objects on the page List selection.
The request below returns the number of active authentication tokens.
AuthToken.count({
"/active": true
})
Creates a new authentication token.
Parameter | Description |
---|---|
patch | An object containing the properties and values to set for the new authentication token. |
query | Which info to return. See Query language. |
The request below creates an authentication token for a new integration with some application X.
AuthToken.create({
"name": "Integration X",
"description": "An authentication key used to write an integration between the webshop and application X."
}, [
"uid"
])
Fetches information about an authentication token.
Parameter | Description |
---|---|
uid | The authentication token. |
query | Which info to return. See Query language. |
The request below checks whether a token is active.
AuthToken.get("YXV0aDpRS4F7bdFom114RO9ygHObnnb/zIOds3iuXFhtoDGbWiUt", [
"active",
"name"
])
Fetches the JSON Schema which can be used for client-side validation.
The authentication token or null
for a new token.
Fetches multiple authentication tokens.
Parameter | Description |
---|---|
query | Which info to return. See Query language. |
selection | Which authentication tokens to list. See List selection. |
The request below lists all active authentication tokens and their names.
AuthToken.list([
"uid",
"name",
"description"
], {
"filters": {
"/active": true
}
})
Creates or updates an authentication token.
Parameter | Description |
---|---|
uid | The authentication token or null to create a new token. |
patch | An object containing the properties and values to set for the authentication token. |
query | Which info to return. See Query language. |
If we suspect that an authentication token has been compromised, instead of deleting it we may deactivate it until we have investigated further whether this is indeed the case. After this request it will not be possible for anyone to use the token to authenticate themselves.
AuthToken.set("YXs8ud9genjknKJDBANKSLdhbwefg234f?/fsIDkjhg3g23fasdD", {
"active": false
}, false)
Parameter | Description |
---|---|
uid | The authentication token or null to create a new token. |
patch | An object containing the properties and values to set for the authentication token. |
Error messages are given as an array of validation-error objects, each containing the keys pointer
(a property referenced using a JSON Pointer) and message
(a readable text in the language of the context).
If there are no validation errors, then an empty array is returned.