-
Notifications
You must be signed in to change notification settings - Fork 0
[PD1-595] Modifying token refresh logic #8
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
Conversation
PD1-595 Token not refreshing when polling data from access DB of ATEK
Showing an Error 404 token has expired when I am polling the ATEK access DB, need to refresh the token |
Summary of ChangesHello @alok27a, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where the token refresh mechanism was not triggering on server redirects, leading to failed requests. The changes modify the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request addresses an issue where the token refresh mechanism was not triggering on server redirects, leading to failed requests. The solution involves disabling automatic redirects, detecting multiple authentication failure patterns, triggering token refresh, handling redirects, and improving error reporting. The changes include modifications to the _make_request() method in cvec.py and the addition of a new test suite in tests/test_token_refresh.py. The code changes look good overall, with a few suggestions for improvement.
joshuanapoli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't treat 3xx as a token expiration. Someday we are likely to use a 3xx response as part of the API, and we'll be confused when some old code here is treating it as if it were a 401 response.
Instead, make sure the system knows that this is a JSON API request, not an HTML request. Add the request accept header for json.
I think that you should change the CloudFront response from 403 to 401 at https://github.com/CVector-Energy/cvec-op-envs/blob/5820478f11b596d9ae8a55c10420fdf5b3571723/terraform/modules/operational_environment/function/cloudfront-function.js#L266
joshuanapoli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! We can test in production, after updating the http status in cvec-op-envs.
Fix: Token Refresh Logic Not Triggering on Server Redirects
Problem
Solution
Key Changes
-Added header in _get_headers() and auth methods.
Improved error handling (specific exceptions: RequestException, ValueError, KeyError).
Added structured logging with stack traces.
Before
After
Benefits
✅ Standards-compliant (RFC 7231)
✅ Backward compatible
✅ No code breakage
✅ Clearer logging & better debugging
Testing
3 new tests added (tests/test_token_refresh.py)
22/22 tests passing
Verified correct 401 handling and refresh trigger