I am having trouble connecting to a third party API using an Authentication header in the format username:password
in a Base64 encode format
Here is my Angular service code: auth.service.ts
import {Injectable} from '@angular/core';
import {HttpEvent, HttpInterceptor, HttpHandler, HttpRequest} from
'@angular/common/http';
import {Observable} from "rxjs/Observable";
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
constructor(){}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>
{
const authReq = req.clone({
setHeaders: {
Authorization: `Basic bWluaXByb2plY3Q6UHIhbnQxMjM=`
}
});
return next.handle(req);
}
}
Here is the app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { AppComponent } from './app.component';
import { AuthInterceptor } from './interceptors/auth.service';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpClientModule
],
providers: [{
provide: HTTP_INTERCEPTORS,
useClass: AuthInterceptor,
multi: true
}],
bootstrap: [AppComponent]
})
export class AppModule { }
Here is the error when I try to connect with at GET call
The SSL certificate used to load resources from https://api... will
be distrusted in M70. Once distrusted, users will be prevented from loading
these resources. See https://g.co/chrome/symantecpkicerts for more
information.
Any direction at all is greatly appreciated. Thanks!