Auth0 Home Blog Docs

How to call HttpClient without HttpInterceptors?

Hi,

I followed the spa angular tutorial to authenticate my user, all works fine but i dont want to use the HttpInterceptor, instead i want to inject the access token myself when needed.

So I try something like this :
get(atUrl: string): Observable {
return this.authService.getTokenSilently$().pipe(
concatMap(token => {
let headers = this.buildHTTPHeader(token);
let url = myurl;
return this.http.get(url, {
headers: headers
});
}),
catchError(err => throwError(err))
);

Can you confirm that the best method to manage token manually in httpClient ?

Thanks