[typescript-axios] Fix Bearer authentication (#2578)

* [typescript-axios] Fix Bearer authentication

It was generated the same as Basic authentication. Now we handle both cases differently.

Fix #1446

* [typescript-axios] Bearer authentication : use config.accessToken instead of config.password

As it is done in the angular client: 0889b8ec13/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache (L213-L220)
This commit is contained in:
Hector Jusforgues 2019-04-05 00:50:48 +02:00 committed by William Cheng
parent 117efe83c0
commit 7dcd488278

View File

@ -74,12 +74,21 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur
}
{{/isKeyInQuery}}
{{/isApiKey}}
{{#isBasic}}
{{#isBasicBasic}}
// http basic authentication required
if (configuration && (configuration.username || configuration.password)) {
localVarHeaderParameter["Authorization"] = "Basic " + btoa(configuration.username + ":" + configuration.password);
}
{{/isBasic}}
{{/isBasicBasic}}
{{#isBasicBearer}}
// http bearer authentication required
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? configuration.accessToken()
: configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
}
{{/isBasicBearer}}
{{#isOAuth}}
// oauth required
if (configuration && configuration.accessToken) {