Angular v19, configuration:
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes),
provideAnimationsAsync(),
provideAuth0({
domain: 'xxx',
clientId: 'yyy',
authorizationParams: {
audience: 'aaa',
redirect_uri: window.location.origin,
},
}),
provideHttpClient(
withInterceptors([authHttpInterceptorFn])
)
]
};
Simple calling:
this.auth.isAuthenticated$.subscribe((isAuthenticated) => {
if (isAuthenticated) {
this.http.get('/api/v1/tests').subscribe((data) => {
console.log(data);
});
}
});
Token is never attached to Authorization header. When I try to get token by auth.getAccessTokenSilently() it works and I get the token.
I could probably build my own interceptor but I would like to use the one made by Auth0.
Angular v19, configuration:
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes),
provideAnimationsAsync(),
provideAuth0({
domain: 'xxx',
clientId: 'yyy',
authorizationParams: {
audience: 'aaa',
redirect_uri: window.location.origin,
},
}),
provideHttpClient(
withInterceptors([authHttpInterceptorFn])
)
]
};
Simple calling:
this.auth.isAuthenticated$.subscribe((isAuthenticated) => {
if (isAuthenticated) {
this.http.get('/api/v1/tests').subscribe((data) => {
console.log(data);
});
}
});
Token is never attached to Authorization header. When I try to get token by auth.getAccessTokenSilently() it works and I get the token.
I could probably build my own interceptor but I would like to use the one made by Auth0.
Share Improve this question asked Mar 14 at 15:52 EdWoodEdWood 9273 gold badges20 silver badges40 bronze badges 01 Answer
Reset to default 1export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes),
provideAnimationsAsync(),
provideAuth0({
domain: 'xxx',
clientId: 'yyy',
authorizationParams: {
audience: 'aaa',
redirect_uri: window.location.origin,
},
httpInterceptor: {
allowedList: [
'/api/*'
],
}
}),
provideHttpClient(
withInterceptors([authHttpInterceptorFn])
)
]
};
Solved. You have to provide two things:
- provideHttpClient with Interceptor
- provideAuth0 with HttpInterceptor config