Fix client headers

This commit is contained in:
Guilherme Werner 2024-08-02 17:41:09 -03:00
parent 2a3c9854e6
commit c441ff7ff5
3 changed files with 19 additions and 6 deletions

View file

@ -126,6 +126,22 @@ export class TribufuClient extends TribufuApi {
return headers;
}
/**
* Get current headers with the api key or access token.
* @returns HeaderMap
*/
protected override getHeaders(): HttpHeaders {
let headers = TribufuClient.defaultHeaders();
headers.set("Authorization", `Basic ${Buffer.from(`${this.clientId}:${this.clientSecret}`, "binary").toString("base64")}`);
if (this.options.accessToken) {
headers.set("Authorization", `Bearer ${this.options.accessToken}`);
return headers;
}
return headers;
}
/**
* Get the client id.
* @returns string