Fix authenticate_jwt_async() to be non-blocking#309
Merged
logan-stytch merged 8 commits intomainfrom Mar 19, 2026
Merged
Conversation
ebab734 to
0c73a7f
Compare
logan-stytch
approved these changes
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Both Consumer and B2B
authenticate_jwt_async()methods aren't fully asynchronous, so it can be blockingThe Consumer one doesn't use an async version of the helper
authenticate_jwt_local()method, whereas the B2B one does:stytch-python/stytch/consumer/api/sessions.py
Line 625 in e28422f
stytch-python/stytch/b2b/api/sessions.py
Line 879 in e28422f
Both Consumer and B2B also call PyJWT's underlying
get_signing_key_from_jwt()method, which is synchronous. The library doesn't seem to support fetching JWKS async: jpadilla/pyjwt#1120This attempts to fix both these issues
Also renames
local_token->local_sessionbecause that makes more senseUnit tests added are vibe coded
Motivation
Community bug report https://app.plain.com/workspace/w_01HAQ5N757DAG0R7JTXZ4MQYKY/thread/th_01KM1BBWC7PMGA2SRS6C9KQQN3/
Testing