🔧 Refactor token retrieval methods in AuthX class#780
Merged
Conversation
- Updated ACCESS_TOKEN and REFRESH_TOKEN properties to use async functions for token retrieval. - Modified get_token_from_request method to accept a Request object and handle token locations more flexibly. - Enhanced documentation for better clarity on token retrieval behavior and usage examples.
- Introduced new async tests for `get_token_from_request` to validate direct access and refresh token retrieval. - Added tests to ensure correct behavior when optional tokens are not provided, including raising appropriate errors. - Refactored token retrieval routes in the FastAPI application to utilize async functions for better performance and clarity.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #780 +/- ##
==========================================
+ Coverage 96.65% 96.67% +0.01%
==========================================
Files 15 15
Lines 778 781 +3
Branches 76 77 +1
==========================================
+ Hits 752 755 +3
Misses 20 20
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…okens - Added method overloads to `get_token_from_request` for better type handling of optional tokens. - Refactored the method implementation to streamline the retrieval process based on the optional flag. - Improved clarity and flexibility in token retrieval logic, ensuring consistent behavior for both required and optional tokens.
|
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.



Fixes: #745
Now you can use it like this
Note
Refactors token retrieval API and dependencies
get_token_from_requestis now an awaitable async method with type-safe overloads and optionallocations, returningOptional[RequestToken]whenoptional=Trueor raising on missing tokenACCESS_TOKEN/REFRESH_TOKENFastAPI dependencies updated to wrap_get_token_from_requestvia local async functions instead of returning a callable fromget_token_from_request_get_token_from_requestnow defaultslocationsto configuredJWT_TOKEN_LOCATIONand cleanly handlesoptionalWritten by Cursor Bugbot for commit 057a858. This will update automatically on new commits. Configure here.