I have created a service that calls to a third party endpoint. I have used their auth endpoint to generate a bearer token which I need to use with other api calls.
Since this is a 3rd party API I'm calling to my target urls and headers are built on a proxy.
Now that I have generated the access_token how can I add this string to the authorisation header?
Component
showOAuth() {
this.zebraService.getOAuth()
.subscribe((data: any) => {
console.log('Zebra Response: ', data);
console.log(data.body);
this.OAuth = data.body;
this.access_token = this.OAuth.access_token;
console.log(this.access_token);
});
}
Proxy
"/zebraAccessApi": {
"target": "https://api.com",
"secure": true,
"changeOrigin": true,
"pathRewrite": {
"^/zebraAccessApi": ""
},
"headers": {
"client_id": "",
"client_secret": ""
}
},
"/zebraSetAppLed": {
"target": "https://api.com/setAppLed",
"secure": true,
"changeOrigin": true,
"pathRewrite": {
"^/zebraSetAppLed": ""
},
"headers": {
"Content-Type": "application/json",
"Authorization": ""
}
}
Service
zebraOAuthUrl = '/zebraAccessApi';
zebraSetAppLedUrl = '/zebraSetAppLed';
public getOAuth() {
let options = {
observe: 'response' as 'body',
response: 'json'
};
return this.http.get(this.zebraOAuthUrl, options);
}
