Skip to content

Commit

Permalink
Add bearer auth to typescript-fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Vanston committed Mar 3, 2019
1 parent e7666b8 commit 82f409c
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,18 @@ export class {{classname}} extends runtime.BaseAPI {
{{/headerParams}}
{{#authMethods}}
{{#isBasic}}
{{#isBasicBasic}}
if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
}

{{/isBasicBasic}}
{{#isBasicBearer}}
// http bearer auth required
if (this.configuration && (this.configuration.accessToken || this.configuration.apiKey)) {
let token = this.configuration.accessToken || this.configuration.apiKey;
headerParameters["Authorization"] = `Bearer ${token}`;
}
{{/isBasicBearer}}
{{/isBasic}}
{{#isApiKey}}
{{#isKeyInHeader}}
Expand Down

0 comments on commit 82f409c

Please sign in to comment.