# Blazor, API, and role based Authorization

**URL:** <https://community.auth0.com/t/blazor-api-and-role-based-authorization/99657>\
**Category:** Get Help\
**Tags:** management-api, roles\
**Created:** [February 3, 2023, 1:37pm UTC](https://community.auth0.com/t/blazor-api-and-role-based-authorization/99657 "2023-02-03T13:37:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakobvj](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jakobvj/32/44304_2.png) [@jakobvj](https://community.auth0.com/u/jakobvj)\
**Post date:** [February 3, 2023, 1:37pm UTC](https://community.auth0.com/t/blazor-api-and-role-based-authorization/99657/1 "2023-02-03T13:37:37Z")

</div>

Hi  
I about to build a .Net Blazor Server application.  
That application then calls a .Net API.

I need authorization in the app and API.  
Like “Admin”, “Customer”, “IT”, etc.  
So they see different things in the app, and are restricted to what they can call in the API.

Would Roles be the way to go?

In .Net role based authorization you can use the Authorize data annotation.

Should i implement it like this tutorial? With customize the token on login?

> **[Blazor Authorization with Auth0 (RBAC)](https://benjaminvertonghen.medium.com/blazor-authorization-with-auth0-rbac-d65cd14acab2)**
>
> In this small series we’ll setup a Blazor Web Assemly Application which communicates with a C# REST API. We’ll protect the endpoints with…

Or what would be a good solution?

Regards  
Jakob

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [February 3, 2023, 1:54pm UTC](https://community.auth0.com/t/blazor-api-and-role-based-authorization/99657/2 "2023-02-03T13:54:00Z")

</div>

Hey there!

Unfortunately we won’t be able to help you with that article as it wasn’t developed by us so it’s hard to share advice on a product that you haven’t invented but we can of course try to help you. Can I redirect you to a better place and ask you to ask this question in on of those threads? Thank you!

> [@Securing Blazor WebAssembly Apps](https://community.auth0.com/t/securing-blazor-webassembly-apps/46661/165):
>
> Hi @Ditchford , I tried to figure out what is happening with your application but honestly I’m afraid I can’t do much. As far as I know, this message is shown when your application comes across a \<NotAuthorized\> element and in the Blazor WASM case, it should happen on the client side (i.e., the server is not involved). For example, in the sample project of my article, this message is shown only once, before the user authentication. This is correct because the current not authenticated user is…

> [@What is Blazor? A Tutorial on Building Web Apps with Authentication](https://community.auth0.com/t/what-is-blazor-a-tutorial-on-building-web-apps-with-authentication/33611/143):
>
> Hey @den783245, Welcome to the Auth0 Community! To enable role-based authorization in your Blazor application, follow the instructions in [this document](https://github.com/auth0/auth0-aspnetcore-authentication/blob/main/EXAMPLES.md#roles). I suggest using [Actions](https://auth0.com/blog/introducing-auth0-actions/) to add the roles to the token instead of rules. After this, you can use the authorization components as explained [here](https://learn.microsoft.com/en-us/aspnet/core/blazor/security#authorization). I hope this helps.

---

<div class="post-metadata">

**Author:** ![jakobvj](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jakobvj/32/44304_2.png) [@jakobvj](https://community.auth0.com/u/jakobvj)\
**Post date:** [February 3, 2023, 3:03pm UTC](https://community.auth0.com/t/blazor-api-and-role-based-authorization/99657/3 "2023-02-03T15:03:20Z")

</div>

Thanks for the reply

I will try using action

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 17, 2023, 3:03pm UTC](https://community.auth0.com/t/blazor-api-and-role-based-authorization/99657/4 "2023-02-17T15:03:23Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
