mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 10:35:25 +00:00
[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:
parent
117efe83c0
commit
7dcd488278
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user