# Unable to get custom claims to work with WPF projects (Access Token) Please help!

**URL:** <https://community.auth0.com/t/unable-to-get-custom-claims-to-work-with-wpf-projects-access-token-please-help/128135>\
**Category:** Get Help\
**Tags:** configuration, application\
**Created:** [February 23, 2024, 6:36am UTC](https://community.auth0.com/t/unable-to-get-custom-claims-to-work-with-wpf-projects-access-token-please-help/128135 "2024-02-23T06:36:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![demariners](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/demariners/32/55086_2.png) [@demariners](https://community.auth0.com/u/demariners)\
**Post date:** [February 23, 2024, 6:36am UTC](https://community.auth0.com/t/unable-to-get-custom-claims-to-work-with-wpf-projects-access-token-please-help/128135/1 "2024-02-23T06:36:36Z")

</div>

I have been trying all day to get this to work. I have a WPF application and authentication works just fine. However I need to be able to know the role of the user or permissions. I have tried to add custom actions and then add it to the login flow. However, every time the Access token and/or the ID token just has the normal OpenID/Profile/Email claims and nothing more.

For some reason I have tried everything. Here is my coding below.

Auth0 Custom Actions/Flow

exports.onExecutePostLogin = async (event, api) =\> {  
const namespace = ‘[https://XXXXXX.us.auth0.com](https://XXXXXX.us.auth0.com)’;  
if (event.authorization) {  
api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);  
api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);  
}  
};

And here is the call within the WPF.

Auth0ClientOptions clientOptions = new Auth0ClientOptions  
{  
Domain = “[XXXXX.us.auth0.com](http://XXXXX.us.auth0.com)”,  
ClientId = “XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”,  
Scope = “openid profile email offline\_access”  
};  
clientOptions.PostLogoutRedirectUri = clientOptions.RedirectUri;

var client = new Auth0Client(clientOptions);

var loginResult = await client.LoginAsync();

---

<div class="post-metadata">

**Author:** ![marcelina.barycka](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marcelina.barycka/32/56162_2.png) [@marcelina.barycka](https://community.auth0.com/u/marcelina.barycka)\
**Post date:** [February 23, 2024, 2:04pm UTC](https://community.auth0.com/t/unable-to-get-custom-claims-to-work-with-wpf-projects-access-token-please-help/128135/2 "2024-02-23T14:04:51Z")

</div>

Hi @demariners !

Could you please try using backquotes ` for the namespace identifier in your Action code? It has to be a string.

```auto
exports.onExecutePostLogin = async (event, api) => {
const namespace = ‘https://XXXXXX.us.auth0.com’;
if (event.authorization) {
api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
}
}

```

Please let us know if that worked!

---

<div class="post-metadata">

**Author:** ![demariners](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/demariners/32/55086_2.png) [@demariners](https://community.auth0.com/u/demariners)\
**Post date:** [February 23, 2024, 3:15pm UTC](https://community.auth0.com/t/unable-to-get-custom-claims-to-work-with-wpf-projects-access-token-please-help/128135/3 "2024-02-23T15:15:09Z")

</div>

That did not work sadly. Is there anything specific I need to put in the scope?

exports.onExecutePostLogin = async (event, api) =\> {  
const namespace = `https://XXXXXX.us.auth0.com`;  
if (event.authorization) {  
api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);  
api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);  
}  
};

---

<div class="post-metadata">

**Author:** ![demariners](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/demariners/32/55086_2.png) [@demariners](https://community.auth0.com/u/demariners)\
**Post date:** [February 23, 2024, 3:16pm UTC](https://community.auth0.com/t/unable-to-get-custom-claims-to-work-with-wpf-projects-access-token-please-help/128135/5 "2024-02-23T15:16:51Z")

</div>

```auto
exports.onExecutePostLogin = async (event, api) => {
  const namespace = `https://deflight.us.auth0.com`;
  if (event.authorization) {
    api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
    api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
  }
};

```

---

<div class="post-metadata">

**Author:** ![demariners](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/demariners/32/55086_2.png) [@demariners](https://community.auth0.com/u/demariners)\
**Post date:** [February 23, 2024, 3:18pm UTC](https://community.auth0.com/t/unable-to-get-custom-claims-to-work-with-wpf-projects-access-token-please-help/128135/6 "2024-02-23T15:18:59Z")

</div>

I also noticed if I type:

[https://XXXXX.us.auth0.com/roles](https://XXXXX.us.auth0.com/roles)

Into my browser I get not found. Not sure if that is because I need to be authenticated or not but just noticed that.

---

<div class="post-metadata">

**Author:** ![marcelina.barycka](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marcelina.barycka/32/56162_2.png) [@marcelina.barycka](https://community.auth0.com/u/marcelina.barycka)\
**Post date:** [February 27, 2024, 2:19pm UTC](https://community.auth0.com/t/unable-to-get-custom-claims-to-work-with-wpf-projects-access-token-please-help/128135/7 "2024-02-27T14:19:40Z")

</div>

@demariners , thank you for following up!

> [@demariners](#):
>
> [https://XXXXX.us.auth0.com/roles](https://XXXXX.us.auth0.com/roles)

This is the namespace identifier and it doesn’t have to be a valid URL.

You should be good with the code snippet I shared. When testing with a test user, please make sure the user has a role assigned.

On your Auth0 tenant, I noticed the only Action applied to the Login flow is the one that adds email address of a logging in user as a claim.

Please also remember to deploy the action once it’s ready. You can have several Actions added to a single flow.

Please let us know how that goes!

---

<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 12, 2024, 2:20pm UTC](https://community.auth0.com/t/unable-to-get-custom-claims-to-work-with-wpf-projects-access-token-please-help/128135/8 "2024-03-12T14:20:31Z")

</div>

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