auth0-python icon indicating copy to clipboard operation
auth0-python copied to clipboard

Async All the Way

Open padrepitufo opened this issue 1 year ago • 1 comments

Changes

I am probably using this wrong and need guidance.

I want to use auth0-python asynchronously. My set up is close to this tutorial. I noticed it depends on PyJWT and I realized the library blocks. I have made an accompanying PR (that this PR points to) but I doubt I'm the first one to use this - I'm probably just using it wrong.

Main change in usage would be (using the tutorial example as my sample):

try:
    signing_key = self.jwks_client.get_signing_key_from_jwt(  # 👈 this lines changes
        token.credentials
    ).key
except jwt.exceptions.PyJWKClientError as error:
    raise UnauthorizedException(str(error))
except jwt.exceptions.DecodeError as error:
    raise UnauthorizedException(str(error))

becomes

try:
    payload  = await self.jwks_client.get_signing_key_from_jwt(  # 👈 this lines changes
        token.credentials
    )
    signing_key = payload.key
except jwt.exceptions.PyJWKClientError as error:
    raise UnauthorizedException(str(error))
except jwt.exceptions.DecodeError as error:
    raise UnauthorizedException(str(error))

References

... None

Testing

Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.

  • [ not yet ] This change adds unit test coverage
  • [ not yet ] This change adds integration test coverage
  • [ partially ] This change has been tested on the latest version of the platform/language or why not no test coverage added because I suspect I'm doing this wrong anyways

Checklist

padrepitufo avatar May 18 '24 17:05 padrepitufo

Any guidance that @evansims @jpadilla @adamjmcgrath could lend would be much appreciated

padrepitufo avatar May 28 '24 20:05 padrepitufo