APIFairy icon indicating copy to clipboard operation
APIFairy copied to clipboard

"Unknown authentication scheme" when using multi_auth

Open spacekbnueve opened this issue 4 years ago • 3 comments

I'm using the following for auth:

basic_auth = HTTPBasicAuth()
token_auth = HTTPTokenAuth('Bearer')
multi_auth = MultiAuth(basic_auth, token_auth)

Then when using authenticate:

@authenticate(multi_auth)

I get the following error:

192.168.223.1 - - [30/Jun/2021 20:53:01] "GET /apispec.json HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/spacekbnueve/.local/share/virtualenvs/project-X5mbx1aO/lib/python3.6/site-packages/flask/app.py", line 2088, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/spacekbnueve/.local/share/virtualenvs/project-X5mbx1aO/lib/python3.6/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.handle_exception(e)
  File "/home/spacekbnueve/.local/share/virtualenvs/project-X5mbx1aO/lib/python3.6/site-packages/flask/app.py", line 2070, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/spacekbnueve/.local/share/virtualenvs/project-X5mbx1aO/lib/python3.6/site-packages/flask/app.py", line 1515, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/spacekbnueve/.local/share/virtualenvs/project-X5mbx1aO/lib/python3.6/site-packages/flask/app.py", line 1513, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/spacekbnueve/.local/share/virtualenvs/project-X5mbx1aO/lib/python3.6/site-packages/flask/app.py", line 1499, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/home/spacekbnueve/.local/share/virtualenvs/project-X5mbx1aO/lib/python3.6/site-packages/apifairy/core.py", line 51, in json
    return dumps(self.apispec), 200, \
  File "/home/spacekbnueve/.local/share/virtualenvs/project-X5mbx1aO/lib/python3.6/site-packages/apifairy/core.py", line 82, in apispec
    self._apispec = self._generate_apispec().to_dict()
  File "/home/spacekbnueve/.local/share/virtualenvs/project-X5mbx1aO/lib/python3.6/site-packages/apifairy/core.py", line 162, in _generate_apispec
    raise RuntimeError('Unknown authentication scheme')
RuntimeError: Unknown authentication scheme

Am I doing something wrong or multi auth is not supported ?

spacekbnueve avatar Jun 30 '21 20:06 spacekbnueve

Only basic and token authentication are currently implemented. I'm not sure what would be the OpenAPI representation for multi auth, I'll have to think about that.

miguelgrinberg avatar Jun 30 '21 21:06 miguelgrinberg

Has there been any traction on this? I'm running in to a need to provide MultiAuth (basic and token). Thanks!

cheizer avatar Jan 03 '24 16:01 cheizer

@cheizer As I stated above, I'm not sure what would the OpenAPI representation for a multi-auth endpoint should be, but if you know what you want in terms of OpenAPI definitions you can easily add your custom stuff in a function decorated with the @process_apispec decorator. See the docs.

miguelgrinberg avatar Jan 03 '24 23:01 miguelgrinberg