# How exactly Rest API Authorization works using Core Authorization Library

**URL:** <https://community.auth0.com/t/how-exactly-rest-api-authorization-works-using-core-authorization-library/24931>\
**Category:** Get Help\
**Tags:** api, authorization\
**Created:** [May 7, 2019, 7:12pm UTC](https://community.auth0.com/t/how-exactly-rest-api-authorization-works-using-core-authorization-library/24931 "2019-05-07T19:12:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkl](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rkl/32/12996_2.png) [@rkl](https://community.auth0.com/u/rkl)\
**Post date:** [May 7, 2019, 7:12pm UTC](https://community.auth0.com/t/how-exactly-rest-api-authorization-works-using-core-authorization-library/24931/1 "2019-05-07T19:12:41Z")

</div>

Hi,  
We are using Auth0 for our User management. Now I am trying to use Authorization for our APIs. I read the documentation to enable RBAC [https://auth0.com/docs/authorization/guides/how-to](https://auth0.com/docs/authorization/guides/how-to)

I understand from documentation, Auth0 API register, creation of Roles and permissions. assigning roles and permissions to users. But I fail to understand how it works end to end and how can I use it for role based authorization for my APIs.  
I was hoping if someone could clear this confusion or guide me in the right documentation.

Thanks.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [May 7, 2019, 9:10pm UTC](https://community.auth0.com/t/how-exactly-rest-api-authorization-works-using-core-authorization-library/24931/2 "2019-05-07T21:10:11Z")

</div>

Hi @rkl,

Welcome to the Auth0 Community!

I would be happy to help with this. Could you give more context on what you would like to do or what the doc is not explaining?

Thanks,  
Dan

---

<div class="post-metadata">

**Author:** ![rkl](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rkl/32/12996_2.png) [@rkl](https://community.auth0.com/u/rkl)\
**Post date:** [May 8, 2019, 2:34am UTC](https://community.auth0.com/t/how-exactly-rest-api-authorization-works-using-core-authorization-library/24931/4 "2019-05-08T02:34:02Z")

</div>

Thank @dan.woda, for your reply.  
I want to use auth0 for role based authorization of my APIs. After setting up roles, permissions etc. mentioned in the enable RBAC docs, how the authorization flow will work. Is Auth0 sufficient for simple Authorization or do I need to develop code at my end for checking roles of users accessing my APIs ?  
And if Auth0 is sufficient, then how can I tell Auth0 which APIs to redirect after Authorization success.

I might be understanding it all wrong. Please help.

Thanks.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [May 8, 2019, 5:16pm UTC](https://community.auth0.com/t/how-exactly-rest-api-authorization-works-using-core-authorization-library/24931/5 "2019-05-08T17:16:41Z")

</div>

I think you have the right idea. You can use [Rules](https://auth0.com/docs/rules) to grant or deny access to certain applications. Take a look here for a brief example:

> **[Rules for Authorization Policies](https://auth0.com/docs/manage-users/access-control/rules-for-authorization-policies)**
>
> Understand how rules apply to authorization policies and Auth0's role-based access system (RBAC).

You can also add Roles to tokens and add your authorization logic that way:

> **[Sample Use Cases: Rules with Authorization](https://auth0.com/docs/manage-users/access-control/sample-use-cases-rules-with-authorization)**
>
> Learn how to use rules with roles-based access control (RBAC). For use with our Authorization Core feature set.

Here is another relevant example of how RBAC and permissions work:

> **[Sample Use Cases: Role-Based Access Control](https://auth0.com/docs/manage-users/access-control/sample-use-cases-role-based-access-control)**
>
> Learn how to implement roles-based authorization (RBAC) in different scenarios and explore how to use rules with RBAC.

Hope this helps,  
Dan

---

<div class="post-metadata">

**Author:** ![chris.olson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris.olson/32/13260_2.png) [@chris.olson](https://community.auth0.com/u/chris.olson)\
**Post date:** [May 16, 2019, 9:49pm UTC](https://community.auth0.com/t/how-exactly-rest-api-authorization-works-using-core-authorization-library/24931/6 "2019-05-16T21:49:09Z")

</div>

One additional question on this: I don’t understand what “enable RBAC” does by itself. I don’t see permissions (permissions assigned to a Role, Role assigned to user) in the access token until I also click “add permissions in the access token”

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [May 17, 2019, 7:34pm UTC](https://community.auth0.com/t/how-exactly-rest-api-authorization-works-using-core-authorization-library/24931/7 "2019-05-17T19:34:42Z")

</div>

@chris.olson,

I think I need more context to understand the questions you are having. Where is the ‘enable RBAC’ you are referring to, and could you please expand on the permissions issue?

Thanks,  
Dan

---

<div class="post-metadata">

**Author:** ![chris.olson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris.olson/32/13260_2.png) [@chris.olson](https://community.auth0.com/u/chris.olson)\
**Post date:** [May 17, 2019, 8:42pm UTC](https://community.auth0.com/t/how-exactly-rest-api-authorization-works-using-core-authorization-library/24931/8 "2019-05-17T20:42:58Z")

</div>

I believe I solved my issue, but please correct me if I’m wrong.

For one of our auth0 defined APIs I did the following:

1. toggled “RBAC enabled” to on under the API settings
2. added a custom permission/scope under this API

I then added this same permission to a Role, then added the Role to a User. When authenticating this user I expected to see the scope (defined in #2 above) in my accessToken. After a good day of playing with this I realized that I also needed to specify the same scope in my auth request (to /oauth/token) in the “scope” query param. The issue may be that I’m not grasping some fundamental oauth concept, but I was hoping the scope would come back in the accessToken regardless if I specified it in my request.

---

<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:** [June 1, 2019, 8:44pm UTC](https://community.auth0.com/t/how-exactly-rest-api-authorization-works-using-core-authorization-library/24931/9 "2019-06-01T20:44:46Z")

</div>

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