okta-jwt-verifier-python
okta-jwt-verifier-python copied to clipboard
Feature request: Support for synchronous applications
Feature request to add new method verify_sync
or verify_blocking
to AccessTokenVerifier
and IDTokenVerifier
that will have the same behavior as verify
but not be async. I see the README has some instructions on how to make sync calls but does not address how to get the JWK synchronously.
We are an Okta customer with a synchronous Python application written in Django. The async implementation for AccessTokenVerifier.verify
and IDTokenVerifier.verify
is causing issues for us. Our application is not written with coroutines and due to other implementation issues, we don't want to use run_until_complete
. We can't rewrite our entire application to be async at this time.
This change would involve a lot of duplicated code to make async methods sync / blocking, but it would allow support for Python code that doesn't use coroutines.
Is there any update on this?
Workaround, making sure to use a new loop if there could already be a running event loop for the Python process:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(jwt_verifier.verify(token))
loop.close()
It would still be better if the code looked like this for example:
jwt_verifier.verify_synchronous(token)