# Custom API integration with Angular

**URL:** <https://community.auth0.com/t/custom-api-integration-with-angular/102367>\
**Category:** Get Help\
**Tags:** management-api, roles\
**Created:** [March 12, 2023, 4:00pm UTC](https://community.auth0.com/t/custom-api-integration-with-angular/102367 "2023-03-12T16:00:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bethmccoy1110](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@bethmccoy1110](https://community.auth0.com/u/bethmccoy1110)\
**Post date:** [March 12, 2023, 4:00pm UTC](https://community.auth0.com/t/custom-api-integration-with-angular/102367/1 "2023-03-12T16:00:57Z")

</div>

So, I created a single-page application on Auth0 and integrated it with my Angular front end. This worked perfectly, and users could log in to my application using Auth0. I however wanted to set up roles/permissions, so created creating a custom API in Auth0. I have connected this API to my python backend and have tested it on the postman.  
My Angular application was already using a python API to perform GET/POST/PUT/DELETE requests.  
I integrated my python API with my auth0 APi using:

```auto
class Auth0JWTBearerTokenValidator(JWTBearerTokenValidator):
    def __init__ (self, domain, audience):
        issuer = f"https://{domain}/"
        jsonurl = urlopen(f"{issuer}.well-known/jwks.json")
        public_key = JsonWebKey.import_key_set(
            json.loads(jsonurl.read())
        )
        super(Auth0JWTBearerTokenValidator, self). __init__ (
            public_key
        )
        self.claims_options = {
            "exp": {"essential": True},
            "aud": {"essential": True, "value": audience},
            "iss": {"essential": True, "value": issuer},
        }

require_auth = ResourceProtector()
validator = Auth0JWTBearerTokenValidator(
    "example",
    "example"
)
require_auth.register_token_validator(validator)

```

I’m am unsure however how to integrate my Auth0 single-page application with my Auth0 custom API via angular. I tried by ‘audience’ to my authModule.route, as seen below:

```auto
AuthModule.forRoot( {
      domain: 'example',
      clientId: 'example',
      audience: 'http://localhost:5000',
  
      authorizationParams: {
        redirect_uri: 'http://localhost:4200',
      },
      

    }) 

```

I have assigned users certain permissions, but when I try to execute API requests as an admin user via my frontend application I am now getting 401 errors, so I don’t believe my application is integrated with my API. Any help would be greatly appreciated!

---

<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:** [March 16, 2023, 5:37pm UTC](https://community.auth0.com/t/custom-api-integration-with-angular/102367/3 "2023-03-16T17:37:13Z")

</div>

Hi @bethmccoy1110,

You should be able to take a look at your token and see if it has the correct claims, including the audience you requested (AKA your API identifier).

[JWT.io](http://JWT.io) is a helpful tool for decoding JWTs. If you have trouble, post an example JWT and we can take a look.

---

<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:** [April 24, 2023, 1:50pm UTC](https://community.auth0.com/t/custom-api-integration-with-angular/102367/4 "2023-04-24T13:50:52Z")

</div>

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