Adding a bearer token header to the service calls

Hello, 
I need to add a http header to all http calls in order to provide security.  
I wrote an angular interceptor that will add this header to all outgoing http calls.
It adds the header just fine to my services, but for the filemanager services, the header does not get added.  I wonder if the file manager services do not go through the angular system?  If so, how can I have my angular app added this security header to the service calls made by the file manager?

Here is my angular interceptor.  The header does not get added to the file manager calls.  
@Injectable()
export class BlobInterceptor implements HttpInterceptor {
  intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
    const token: string = localStorage.getItem('token');
    request = request.clone({ headers: request.headers.set('Authorization', 'Bearer ' + token) });
    return next.handle(request).pipe(
      map((event: HttpEvent<any>) => {
        if (event instanceof HttpResponse) {
          console.log('event--->>>', event);
        }
        return event;
      }));
  }
}


Thank you.

3 Replies 1 reply marked as answer

SP Sowmiya Padmanaban Syncfusion Team October 26, 2020 07:39 AM UTC

Hi Jason McCoy,  
 
Greetings from Syncfusion support. 
 
Based on your shared details, we suspect that you are expecting to send the token to the server side for each request. You can achieve your requirement by using beforeSend event of FileManager component.  
 
We have already addressed similar requirement in FileManager component. Refer the below forum link for your reference. 
 
 
Refer to the below links to know more about the FileManager component. 
 
 
 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P 


Marked as answer

JM Jason McCoy October 26, 2020 02:19 PM UTC

Thank you,
Yes I saw the other post, but I wanted to accomplish this via a angular interceptor ideally.  I guess it cannot be done that way.


SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team October 27, 2020 11:35 AM UTC

Hi Jason, 
 
Thanks for the update. 
 
We suggest you add the bearer token to FileManager’s request headers as using its beforeSend event to meet your expected requirement. 
 
Please, get back to us if you need any further assistance. 
 
Regards, 
Shameer Ali Baig S. 


Loader.
Up arrow icon