Defining security component like
"components": {
"securitySchemes": {
"bearerAuth": {
"type": "http",
"scheme": "bearer"
}
}
},
"security": [
{
"bearerAuth": []
}
]
When I generate a python client, the API configuration code only allows for type: basic.
In configuration.py:
def auth_settings(self):
"""Gets Auth Settings dict for api client.
:return: The Auth Settings information dict.
"""
return {
'bearerAuth':
{
'type': 'basic',
'in': 'header',
'key': 'Authorization',
'value': self.get_basic_auth_token()
},
}
3.3.3
Does #1207 address this?
Ideally this would be something like
return {
'bearerAuth':
{
'type': 'http',
'in': 'header',
'key': 'Authorization',
'value': 'Bearer ' + self.token
},
}
Does #1207 address this?
As you may already notice. Nope, referenced PR adds token authentication feature to PHP Slim Server generator only.
@tomplus As new Python committee, can you answer this?
As we can find here /resources/python/configuration.mustache the bearer token will work only if the type equals oauth2.
I'm not real familiar with mustache.. Shouldn't we be able to add another block for type http? Perhaps a default if oauth2 is not set?
In my opinion that should be changed, as the OpenApi allows Bearer authentication without OAuth.
I've tested the proposal by vmorris:
Ideally this would be something like
return { 'bearerAuth': { 'type': 'http', 'in': 'header', 'key': 'Authorization', 'value': 'Bearer ' + self.token }, }
Adding this and of course the token attribute does the job quite well. I'm not too familiar with the template syntax, though
Hi all, I've filed https://github.com/OpenAPITools/openapi-generator/pull/1999 to add the Bearer authentication support to the Python client. Please review when you've time.
Closing this for the time being.
@wing328 sorry it took some time for me to come back to that project. I was testing it today using the current master snapshot docker image and it works perfectly. Thanks for your work!
is this fix released in 3.X version? in my generated code there's no bearerAuth in the auth_setting(self) it should have something like this (note: what should be the identifier ?)
'bearerAuth':
{
'type': 'http',
'in': 'header',
'key': 'Authorization',
'value': self.get_api_key_with_prefix('<THEPREFIX>')
},
@esseti this went into the 4.0.0 milestone