# Role Permissions in Blazor Server App

**URL:** <https://community.auth0.com/t/role-permissions-in-blazor-server-app/129446>\
**Category:** Get Help\
**Tags:** management-api, roles\
**Created:** [March 11, 2024, 4:01pm UTC](https://community.auth0.com/t/role-permissions-in-blazor-server-app/129446 "2024-03-11T16:01:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![olivier.vanheste](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@olivier.vanheste](https://community.auth0.com/u/olivier.vanheste)\
**Post date:** [March 11, 2024, 4:01pm UTC](https://community.auth0.com/t/role-permissions-in-blazor-server-app/129446/1 "2024-03-11T16:01:54Z")

</div>

Hi,

I’m new to Auth0 and I’ve been playing around with it and so far everything works as expected. However I have a problem that I couldn’t find a straight answer too and I don’t know if this is at all possible.

I have a blazore server app and a [asp.net](http://asp.net) core api.  
In Auth0 I’ve created a API and added some permissions to it. I’ve then created some roles and added the permisssion to those roles. Finally I’ve added the roles to users. When I’m now I can now connect to the API part and get my permissions. that are assigned to the role that the user has.

Now I would like to retrieve these role permissions in my Blazor server app to had certain parts of the interface based on those permissions.

for example: User has products.read =\> he should be able to see the page products.  
an icon/button would become visible if the user has a role with the permission product.update

Would anyone be able to assist me with this? I’ve been struggling with this for a couple of days now.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [March 11, 2024, 11:41pm UTC](https://community.auth0.com/t/role-permissions-in-blazor-server-app/129446/3 "2024-03-11T23:41:30Z")

</div>

Hey there @olivier.vanheste !

> [@olivier.vanheste](#):
>
> Now I would like to retrieve these role permissions in my Blazor server app to had certain parts of the interface based on those permissions.
> 
> for example: User has products.read =\> he should be able to see the page products.  
> an icon/button would become visible if the user has a role with the permission product.update
> 
> Would anyone be able to assist me with this? I’ve been struggling with this for a couple of days now.

Completely agnostic to tech stack, this is typically achieved by adding permission to access tokens - The easiest way to do this is by [enabling the option](https://auth0.com/docs/get-started/apis/enable-role-based-access-control-for-apis) in the settings of the API registered in Auth0.

---

<div class="post-metadata">

**Author:** ![olivier.vanheste](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@olivier.vanheste](https://community.auth0.com/u/olivier.vanheste)\
**Post date:** [March 12, 2024, 10:02am UTC](https://community.auth0.com/t/role-permissions-in-blazor-server-app/129446/4 "2024-03-12T10:02:08Z")

</div>

Hi @ty.frith ,

Thanks for the response indeed I used this toggle button and this enabled me to call my API in context of a user.

However in my use case I’ve just authenticated and I want to load the pages. When I’m requesting an access\_token for the API it will indeed contain the role permissions. However in my Blazor Server App, the identity\_token is being checked.

I was able to add the roles to this token with actions, but I can’t seem to find a way to add the persmissions.

My code in the Blazor Server App is the following:

```auto
builder.Services.AddAuth0WebAppAuthentication(options =>
{
    options.Domain = builder.Configuration["Auth0:Domain"];
    options.ClientId = builder.Configuration["Auth0:ClientId"];
    // new line
    options.ClientSecret = builder.Configuration["Auth0:ClientSecret"];
    options.Scope = "openid profile email";

}).WithAccessToken(options =>
{
    options.Audience = builder.Configuration["Auth0:Audience"];
});

```

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [March 12, 2024, 3:46pm UTC](https://community.auth0.com/t/role-permissions-in-blazor-server-app/129446/5 "2024-03-12T15:46:43Z")

</div>

Gotcha! Thanks for clarifying 🙂 You could _infer_ permissions from roles (this is a common practice) or you will need to add them in additional steps:

> [@Adding user permission to the id-token](https://community.auth0.com/t/adding-user-permission-to-the-id-token/102853/3):
>
> Hi @stehranchi, Welcome to the Auth0 Community! There are quite a few posts in the forum about this:

---

<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:** [March 26, 2024, 3:46pm UTC](https://community.auth0.com/t/role-permissions-in-blazor-server-app/129446/6 "2024-03-26T15:46:48Z")

</div>

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