Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support for synchronous applications #42

Open
jshields opened this issue Jul 6, 2022 · 2 comments
Open

Feature request: Support for synchronous applications #42

jshields opened this issue Jul 6, 2022 · 2 comments

Comments

@jshields
Copy link

jshields commented Jul 6, 2022

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.

@dee-corr
Copy link

Is there any update on this?

@jshields
Copy link
Author

jshields commented Aug 27, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants