Token#
A string generated and used by PEM REST APIs for authentication purposes
TokenGeneration#
Code samples
# You can also use wget
curl -X POST https://PEM-SERVER-IP/api/token/ \
-H Content-Type: application/json \
-H Accept: application/json
import requests
headers = {
Content-Type: application/json,
Accept: application/json
}
r = requests.post(https://PEM-SERVER-IP/api/token/, headers = headers)
print(r.json())
const inputBody = {
"username": "string",
"password": "string"
};
const headers = {
Content-Type:application/json,
Accept:application/json
};
fetch(https://PEM-SERVER-IP/api/token/,
{
method: POST,
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
POST /token/
Generate a token for authentication.*
This URL creates a token to be used by the other REST APIs exposed by PEM. You must provide a valid username and password, which will be validated during the process.
The token will be valid for 20 mins.
Body parameter
{
"username": "string",
"password": "string"
}
Parameters#
Name |
In |
Type |
Required |
Description |
|---|---|---|---|---|
body |
body |
object |
true |
Creates the token using the /token/ URL first. |
» username |
body |
string |
true |
Validates username, which has pem_user role. |
» password |
body |
string |
true |
Password for the username |
Example responses
{
"issuedAt": "2019-08-24T14:15:22Z",
"expiresAt": "2019-08-24T14:15:22Z",
"schema_version": 0,
"backend_schema_version": 0,
"version_long": 0,
"version": "string",
"supported_api_versions": [
"string"
],
"deprecated_api_versions": [
"string"
]
}
Responses#
Status |
Meaning |
Description |
Schema |
|---|---|---|---|
201 |
Token was created and can be found as 'X-Subject-Token' in the response header. |
Inline |
|
401 |
The given information is not valid. |
None |
|
500 |
Something went wrong. |
None |
|
503 |
PEM backend database server is down. Service is not available now. |
None |
Response Schema#
Status Code 201
Contains information related to when the token was generated and when it expired.*
Name |
Type |
Required |
Restrictions |
Description |
|---|---|---|---|---|
» issuedAt |
string(date-time) |
false |
none |
Token was generated at this time. |
» expiresAt |
string(date-time) |
false |
none |
Provides date and time when the token expires. |
» schema_version |
integer |
false |
none |
Application-supported schema version |
» backend_schema_version |
integer |
false |
none |
Backend database schema version |
» version_long |
integer |
false |
none |
Version represented in long format |
» version |
string |
false |
none |
String reprentation of the PEM version |
» supported_api_versions |
[string] |
false |
none |
List of supported API versions |
» deprecated_api_versions |
[string] |
false |
none |
List of deprecated API versions |
Response Headers#
Status |
Header |
Type |
Format |
Description |
|---|---|---|---|---|
201 |
X-Subject-Token |
string |
Returns the new token, which can be used with REST APIs for further operations |
delete_token#
Code samples
# You can also use wget
curl -X DELETE https://PEM-SERVER-IP/api/token/ \
-H X-Auth-Token: string
import requests
headers = {
X-Auth-Token: string
}
r = requests.delete(https://PEM-SERVER-IP/api/token/, headers = headers)
print(r.json())
const headers = {
X-Auth-Token:string
};
fetch(https://PEM-SERVER-IP/api/token/,
{
method: DELETE,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
DELETE /token/
Release the token.*
Invalidates the token. It will no longer be available for further operations.
Parameters#
Name |
In |
Type |
Required |
Description |
|---|---|---|---|---|
X-Auth-Token |
header |
string |
true |
Token of authorization |
Example responses
Responses#
Status |
Meaning |
Description |
Schema |
|---|---|---|---|
204 |
Successfully released the token from PEM. |
||
This token can not be used for any further operations. |
None |