Below is an overall view of the database tables. Note that ROLES and USERROLES are explicity used for authorization and should be ignored by the front end.
You can test endpoints straight from your browser by using the interactive app Here
A bearer token is required to access endpoints. A token can be acquired for NEW USERS by making a POST request at:
http://wlist-java.herokuapp.com/registerPOST Request Shape:
{
"username": "myUsername",
"password": "myPassword",
"email": "myEmail@email.com"
}On success, the generated response should look like this:
{
"access_token": "7cbc862b-b82d-4546-bde1-b9a58b21dc76",
"token_type": "bearer",
"scope": "read trust write"
}You may now use the newly acquired token to access all endpoints that don't require an Admin status. To make and ADMIN account, simply include the word admin in your username:
"username": "admin_name",
"password": "myPassword",
"email": "myEmail@email.com"To log a user in and generate their token, you will have to make a POST request here:
http://wlist-java.herokuapp.com/loginThis requires some headers on the request. An example is given below on how to handle this.
axios.post("http://wlist-java.herokuapp.com/login", `grant_type=password&username=${this.state.username}&password=${this.state.password}` , {
headers: {
Authorization: `Basic ${btoa('lambda-client:lambda-secret')}`,
"Content-Type": "application/x-www-form-urlencoded"
}
})
.then( res => {
localStorage.setItem("token", res.data.access_token);
})Everything should be left how it is except how you want to handle the response on .then, and the USERNAME and PASSWORD. This should be the same username and password when you created an account using the register endpoint.
