# Angular frontend communicating with FastAPI does not seem to send the my custom scopes

**URL:** <https://community.auth0.com/t/angular-frontend-communicating-with-fastapi-does-not-seem-to-send-the-my-custom-scopes/66244>\
**Category:** Get Help\
**Tags:** fastapi, angular\
**Created:** [July 15, 2021, 3:57pm UTC](https://community.auth0.com/t/angular-frontend-communicating-with-fastapi-does-not-seem-to-send-the-my-custom-scopes/66244 "2021-07-15T15:57:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![evert](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evert/32/30553_2.png) [@evert](https://community.auth0.com/u/evert)\
**Post date:** [July 15, 2021, 3:57pm UTC](https://community.auth0.com/t/angular-frontend-communicating-with-fastapi-does-not-seem-to-send-the-my-custom-scopes/66244/1 "2021-07-15T15:57:38Z")

</div>

I have based on your examples created an Angular 11 SPA (running locally on port 4200) which communicates with a FastAPI based backend (running locally on localhost port 8080). I am using the package ‘fastapi-auth0’. Now although authentication works, my custom scope is not send with the token. The content of the token is ‘‘openid profile email’’.

Because on the Angular site my httpInterceptor is defined as:

```auto
      AuthModule.forRoot({
            domain: '<my domain>',
            clientId: '<my client id>'',

            // Request this audience at user authentication time
            audience: 'https://<my API audience>',

            // Request this scope at user authentication time
            scope: 'read:measurements',

            // Specify configuration for the interceptor
            httpInterceptor: {
                allowedList: [
                    {
                        // Match any request that starts with the uri defined below (note the asterisk)
                        uri: 'http://127.0.0.1:8080/*',
                        tokenOptions: {
                            // The attached token should target this audience
                            audience: '<my API audience>',

                            // The attached token should have these scopes
                            scope: 'read:measurements'
                        }
                    }
                ]
            }
        })

```

I would have expected the scope to contain ‘read:measurements’ too.  
I have defined this in the ‘Permissions’ tab, by the way and enabled ‘RBAC’ and ‘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:** [July 15, 2021, 8:01pm UTC](https://community.auth0.com/t/angular-frontend-communicating-with-fastapi-does-not-seem-to-send-the-my-custom-scopes/66244/3 "2021-07-15T20:01:24Z")

</div>

Hi @evert,

Welcome to the Auth0 Community!

Are you not seeing the custom scope at all in the token? Your scope should be included _in the token_. Are you not seeing it there?

---

<div class="post-metadata">

**Author:** ![evert](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evert/32/30553_2.png) [@evert](https://community.auth0.com/u/evert)\
**Post date:** [July 15, 2021, 8:34pm UTC](https://community.auth0.com/t/angular-frontend-communicating-with-fastapi-does-not-seem-to-send-the-my-custom-scopes/66244/4 "2021-07-15T20:34:05Z")

</div>

Thanks for replying to my message. Yes, I see the scope in the token. For convenience I have included a screenshot of debugging output of the ‘payload’ variable of the libraries ‘auth.py’.

![Payload](https://global.discourse-cdn.com/auth0/original/3X/2/c/2c2d28b7d60c60cd99265678a4a91028e56deedc.png)

---

<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:** [July 16, 2021, 5:11pm UTC](https://community.auth0.com/t/angular-frontend-communicating-with-fastapi-does-not-seem-to-send-the-my-custom-scopes/66244/5 "2021-07-16T17:11:07Z")

</div>

Have you assigned the permission to the user directly or implicitly via a role?

---

<div class="post-metadata">

**Author:** ![evert](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evert/32/30553_2.png) [@evert](https://community.auth0.com/u/evert)\
**Post date:** [July 18, 2021, 10:43am UTC](https://community.auth0.com/t/angular-frontend-communicating-with-fastapi-does-not-seem-to-send-the-my-custom-scopes/66244/6 "2021-07-18T10:43:19Z")

</div>

Well, thank you very much for pointing me into the right direction. This greenhorn completely misunderstood the concept of scoped API protection: I had the assumption that the httpInterceptor was sending the allowed scopes. I was already wondering how this is managed per user.

Now I see: when a user is registered into Auth0, I need to go to this user and assign manually the allowed scopes.

It now works.

Still makes me wonder why the httpInterceptor is defined with an ‘audience’ and a ‘scope’ because when I comment this out it works too.

---

<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:** [July 19, 2021, 3:29pm UTC](https://community.auth0.com/t/angular-frontend-communicating-with-fastapi-does-not-seem-to-send-the-my-custom-scopes/66244/7 "2021-07-19T15:29:50Z")

</div>

@evert,

You may be defining the audience for your custom API somewhere else in your Angular app, or have set a tenant-wide default audience. The `https://{YOUR-TENANT}.eu.auth0.com/userinfo` audience is a default.

---

<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:** [August 3, 2021, 3:30pm UTC](https://community.auth0.com/t/angular-frontend-communicating-with-fastapi-does-not-seem-to-send-the-my-custom-scopes/66244/8 "2021-08-03T15:30:14Z")

</div>

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