I am using the Azure AD adal library to do authentication. There is a call to aquire a token that returns an observable. How can this observable be added into the intercept? In the below example, how can I get the request that is set inside the subscribe to be returned as the Observable?
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
this.authAzureService.getAccessToken()
.subscribe(token => {
// I need this to be returned
request = this.getRequestWithHeaders(request, token);
});
// This returns the request before the access token is added
return next.handle(request);
}