mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 19:08:52 +00:00
[typescript-fetch] add bearer token support (#3097)
* [typescript-fetch] added Bearer token support * [typescript-fetch] executed ./bin/openapi3/typescript-fetch-petstore-all.sh * [typescript-fetch] executed ./bin/typescript-fetch-petstore-all.sh
This commit is contained in:
parent
6660b74247
commit
cd85210835
@ -107,10 +107,21 @@ 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}}
|
||||
if (this.configuration && (this.configuration.accessToken || this.configuration.apiKey)) {
|
||||
const token = this.configuration.accessToken || this.configuration.apiKey;
|
||||
const tokenString = typeof token === 'function' ? token("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]) : token;
|
||||
|
||||
if (tokenString) {
|
||||
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
||||
}
|
||||
}
|
||||
{{/isBasicBearer}}
|
||||
{{/isBasic}}
|
||||
{{#isApiKey}}
|
||||
{{#isKeyInHeader}}
|
||||
|
Loading…
Reference in New Issue
Block a user