Bearer auth seems to not work with python codegen
See original GitHub issueBug Report Checklist
my spec has this:
components:
securitySchemes:
xxx:
type: http
scheme: bearer
responses:
GenericApiError:
description: this object is returned in the cases when an API throws an exception
content:
application/json:
schema:
$ref: '#/components/schemas/JsonSerializedException'
security:
- xxx: []
after generating the code, i see this in the code:
configuration.py:
def get_basic_auth_token(self):
"""Gets HTTP basic authentication header (string).
:return: The token for basic HTTP authentication.
"""
return urllib3.util.make_headers(
basic_auth=self.username + ':' + self.password
).get('authorization')
def auth_settings(self):
"""Gets Auth Settings dict for api client.
:return: The Auth Settings information dict.
"""
return {
}
Description
code doesn’t use bearer token in the requests
openapi-generator version
java -jar openapi-generator-cli.jar version
5.0.1
OpenAPI declaration file content or url
Generation Details
java -jar openapi-generator-cli.jar generate -i portal-services-openapi.yaml -g python -o portal_client
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/1577
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Python bearerAuth not generated · Issue #10060 - GitHub
Let me explain: f the auth_settings is created as in my sample, it works. BUT there's a problem, since the get_api_key_with_prefix wants a...
Read more >openapi - How can I represent 'Authorization: Bearer <token ...
Workaround for me was to put Bearer xxxxxxxx as the key in the UI authorization box. This worked, though the drawback is telling...
Read more >How to Use Swagger Inspector
If you don't have any authentication, headers, or query parameters to add, ... add the Authorization: Bearer header and ask you for the...
Read more >Security - First Steps - FastAPI
If it doesn't see an Authorization header, or the value doesn't have a Bearer token, it will respond with a 401 status code...
Read more >How do I Send a GET Request with Bearer Token ... - ReqBin
Bearer Authentication (also called token authentication) is an HTTP authentication scheme created as part of OAuth 2.0 but is now used on its ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
we decided against modifying the generated code itself, we are just passing extra headers to the calls, that way we can still use the generated code. @AlfredoCubitos
@4c74356b41 Yes, this is a better solution 👍