Latest Angular with a .net 5 back end api

I’ve been searching form posts and reading guides but nothing seems to work and there maybe 100’s of ways to do it, but… non of them seem right.

I have a simple setup. I have a single page app running in the latest angular. I also have a .net 5 rest back end.

Right now, a user can login to my angular application and auth.user$ has data and seems to be working. I think configured the AuthModule like this: (client id and domain redacted)

import { AuthHttpInterceptor, AuthModule } from ‘@auth0/auth0-angular’

AuthModule.forRoot({
domain: ‘redacted’,
clientId: ‘redacted’,
scope: ‘read:api’,
httpInterceptor: {
allowedList: [
‘*’
]}
providers: [
{
provide: HTTP_INTERCEPTORS,
useClass: AuthHttpInterceptor,
multi: true
},

I don’t think the jwt is getting to the into the header of my api call.
The response I get back from my API is this Bearer error=“invalid_token”
and the token, when I check, is not a JWT.

I’m assuming my api is setup correctly. (it probably isn’t) but if I can’t get a proper JWT to the api, I’ll never know. If I could create a JWT manually and use postman that would help for that section too.

So first question, how do I get a jwt instead of what ever is being passed now?

Hi @bradsharp54,

Welcome to the Community!

You token is likely not a JWT because you are not passing your API as the audience in the auth request.

Here is a FAQ that explains it:

Here is our angular example that shows how to include an audience (this should be the identifier of your API that you have registered in the Auth0 dashboard). I would recommend looking over this document as is explains it in detail.

I’m not sure how I missed that but thanks for pointing something so simple out! I have it all working now and it really didn’t take me more than a day to setup.

Thanks again

Brad

1 Like

Awesome! Glad you found a solution!

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