# Access\_denied (Cannot read property 'userRole' of undefined)

**URL:** <https://community.auth0.com/t/access-denied-cannot-read-property-userrole-of-undefined/78850>\
**Category:** Get Help\
**Created:** [February 24, 2022, 12:36pm UTC](https://community.auth0.com/t/access-denied-cannot-read-property-userrole-of-undefined/78850 "2022-02-24T12:36:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rj03012002](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rj03012002/32/34963_2.png) [@rj03012002](https://community.auth0.com/u/rj03012002)\
**Post date:** [February 24, 2022, 12:36pm UTC](https://community.auth0.com/t/access-denied-cannot-read-property-userrole-of-undefined/78850/1 "2022-02-24T12:36:36Z")

</div>

I am getting this error when i am calling auth0.getAccessToken() function in my next.js application

Auth0 logs -  
{  
“code”: 500,  
“error”: “Script generated an unhandled asynchronous exception.”,  
“details”: “TypeError: Cannot read property ‘userRole’ of undefined”,  
“name”: “TypeError”,  
“message”: “Cannot read property ‘userRole’ of undefined”,  
“stack”: “TypeError: Cannot read property ‘userRole’ of undefined\n at setRolesToUser (/data/io/node12/d4c3c024-9c8f-4b9a-89e0-06ddf55117cf/webtask.js:41:49)\n at fn (/data/sandbox/node12/node\_modules/auth0-authz-rules-api/node\_modules/async/lib/async.js:638:34)\n at Immediate. (/data/sandbox/node12/node\_modules/auth0-authz-rules-api/node\_modules/async/lib/async.js:554:34)\n at processImmediate (internal/timers.js:461:21)\n at process.topLevelDomainCallback (domain.js:138:15)\n at process.callbackTrampoline (internal/async\_hooks.js:124:14)”  
}

Code generated an uncaught exception: TypeError: Cannot read property ‘userRole’ of undefined  
at setRolesToUser (/data/io/node12/d4c3c024-9c8f-4b9a-89e0-06ddf55117cf/webtask.js:41:49)  
at fn (/data/sandbox/node12/node\_modules/auth0-authz-rules-api/node\_modules/async/lib/async.js:638:34)  
at Immediate. (/data/sandbox/node12/node\_modules/auth0-authz-rules-api/node\_modules/async/lib/async.js:554:34)  
at processImmediate (internal/timers.js:461:21)  
at process.topLevelDomainCallback (domain.js:138:15)  
at process.callbackTrampoline (internal/async\_hooks.js:124:14)

---

<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 24, 2022, 2:00pm UTC](https://community.auth0.com/t/access-denied-cannot-read-property-userrole-of-undefined/78850/2 "2022-02-24T14:00:08Z")

</div>

Hey there!

What i would suggest here is to raise a GitHub issue in the next.js sdk repo so we can discuss that directly with the repo maintainers. Once you create make sure to share it here with us so we can ping them. Thank you!

---

<div class="post-metadata">

**Author:** ![rj03012002](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rj03012002/32/34963_2.png) [@rj03012002](https://community.auth0.com/u/rj03012002)\
**Post date:** [February 24, 2022, 2:32pm UTC](https://community.auth0.com/t/access-denied-cannot-read-property-userrole-of-undefined/78850/3 "2022-02-24T14:32:09Z")

</div>

[Access\_denied (Cannot read property ‘userRole’ of undefined) · Issue #601 · auth0/nextjs-auth0 · GitHub](https://github.com/auth0/nextjs-auth0/issues/601) i have created a issue here.

---

<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 25, 2022, 8:25am UTC](https://community.auth0.com/t/access-denied-cannot-read-property-userrole-of-undefined/78850/4 "2022-02-25T08:25:17Z")

</div>

Perfect! I’ll ping repo maintainers in a few minutes!

---

<div class="post-metadata">

**Author:** ![rj03012002](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rj03012002/32/34963_2.png) [@rj03012002](https://community.auth0.com/u/rj03012002)\
**Post date:** [February 25, 2022, 9:30am UTC](https://community.auth0.com/t/access-denied-cannot-read-property-userrole-of-undefined/78850/5 "2022-02-25T09:30:23Z")

</div>

@konrad.sopala The problem is solved. thanks for helping 😁

---

<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 25, 2022, 9:37am UTC](https://community.auth0.com/t/access-denied-cannot-read-property-userrole-of-undefined/78850/6 "2022-02-25T09:37:14Z")

</div>

Perfect! Glad to hear that!

---

<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, 2022, 9:38am UTC](https://community.auth0.com/t/access-denied-cannot-read-property-userrole-of-undefined/78850/7 "2022-03-12T09:38:07Z")

</div>

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