To generate a token make a POST request to the endpoint /auth/user/username/sign_in
with the following payload
Payload
{
"user":
{
"username": "username",
"password": "password"
}
}
With the correct credentials you will get a response similar to the one below
Response
{
"authentication":
{
"success": true,
"token": "token"
}
}
The token can now be used in any request by adding a HTTP Header called Authorization and with the following content Bearer <token>
Example (Javascript)
const token = "mytoken";
const myBody = "content";
const response = await fetch('https://api.maskon.no/someendpoint', {
method: 'POST',
body: myBody,
headers: {
'Content-Type': 'application/vnd.api+json',
'Authorization': 'Bearer ' + token
}
});