Accessing endpoints with role-based access in the client application
How to access a secured endpoint from a client app? How to determine if a certain action is available to the current user and enable corresponding UI elements? We will address these questions in this recipe.
We’ll build upon the application from the previous recipe. After a user logs in, their email will be displayed in the window title. We will also load data from an endpoint that is accessible only to authenticated users. Additionally, we’ll add a Delete button that will be visible only to users with the Admin
role.
Getting ready
Start with the project you completed in the previous recipe (Implementing role-based access rules on the server). This project is available at https://github.com/PacktPublishing/.NET-MAUI-Cookbook/tree/main/Chapter05/c5-RoleBasedAccessPart1.
The code for this recipe is available at https://github.com/PacktPublishing/.NET-MAUI-Cookbook/tree/main/Chapter05/c5-RoleBasedAccessPart2...