Secure endpoints

Secure endpoints are only accessible to authenticated users. This means that users need to login before doing a request to these endpoints.

The endpoint expects a valid Access token, which is generated during login and stored in a httpOnly cookie. To include this token in the request you need to use the credentials flag in the request options.

Login:

// using axios
axios({
method: 'POST',
url: 'https://app.yawe.dev/api/1/ce/examples/auth?key=d59eb2859c284168ac48aef65046d5dd&login=true',
data: { username: 'username', password: 'password' } // login credentials
});
// using fetch
fetch('https://app.yawe.dev/api/1/ce/examples/auth?key=d59eb2859c284168ac48aef65046d5dd&login=true', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({ username: 'username', password: 'password' }) // user credentials
});

Accessing a secure endpoint:

// using axios
axios({
method: 'GET',
url: 'https://app.yawe.dev/api/1/ce/secure-endpoint?key=d59eb2859c284168ac48aef65046d5dd',
withCredentials: true
});
// using fetch
fetch('https://app.yawe.dev/api/1/ce/secure-endpoint?key=d59eb2859c284168ac48aef65046d5dd', {
credentials: 'include',
method: 'GET',
});