IndominusByte/fastapi-jwt-auth

Using AuthJWT for token creation only?

vaizki opened this issue · 1 comments

I have an OAuth2 password flow authorization endpoint which is used to create a token. However if I inject AuthJWT as a dependency, the request will fail as there is an Authorization: Basic <basicauth in base64> header in the request, containing client_id and client_secret.

I would still like to use the utility functions create_access_token etc. So currently I just derive a dummy class like this:

class DummyAuthJWT(AuthJWT):
    def __init__(self, req = None, res = None):
        pass

.. and inject that so that I don't get the header verification exception.

Is there a cleaner way to access the token creation only?

I have a similar need. I would like to generate tokens for an API service using a command line tool. So neither a request nor response will ever exist. Will try it with such a wrapper class.