API — User Operations
This guide contains all API operations related to users.
Register a User
The first action to perform should be to register the user. We’ll make use of the
access_token
copied in the previous section to make an authenticated API call to the /register
endpoint.
The access_token
contains various claims within the token. These include:
- preferred_username
- given_name
- family_name
These values are decrypted in the back-end application and used to insert a new user object into
the database. A unique userID
will be generated upon successful insertion of the new user.
This “localized” userID
value is used throughout the application to keep track of user
specific data.
-
Perform a
GET
request: -
This should provide a response like:
-
There is no response body, and the HTTP status code is
HTTP 201 Created
Retrieve a list of all Users
In order to retrieve a list of all users in the system make an authenticated API call to the
/users
endpoint.
-
Perform a
GET
request: -
This should provide a response like:
-
Take note of the
userID
value and copy it, in the next section you’ll make use of that value to update the user.
Update a User by UserID
In order to update a specific user’s details, it is required to pass in the userID
as a
path parameter. In this case, take the userID
value from the previous section:
1c529433-063f-40c2-8dba-4d5a8197fd5b
.
You’ll see that there is no request body attached with the request. This is because the same
principles apply that you find in the /register
(register user) endpoint.
For the purpose of this guide, I have logged into the Keycloak server and changed the surname
value for the user from Smulders
to UpdatedSurname
. In order for the access_token
to
retrieve the latest information, I performed another login and subsequently updated the token in
the requests.
Again, this will be handled automatically once the front-end application is integrated and released. I will also update this guide when that happens.
-
Perform a
PUT
request: -
This should provide a response like:
-
Take note of the
lastName
value. It has been updated fromSmulders
toUpdatedSurname
Get a User by UserID
In order to retrieve a specific user’s details, it is required to pass in the userID
as a
path parameter. In this case, take the userID
value from the previous section:
1c529433-063f-40c2-8dba-4d5a8197fd5b
.
-
Perform a
GET
request: -
This should provide a response like:
-
The response is a single
User
object.
Summary
Endpoints covered in this guide are as follows:
GET /users/register
- Registers the new user in the back-end database
GET /users
- Retrieve all users in the system
PUT /users/<userID>
- Update a specific user based on the
userID
value
- Update a specific user based on the
GET /users/<userID>
- Retrieve a single user based on the
userID
value
- Retrieve a single user based on the