-
-
Notifications
You must be signed in to change notification settings - Fork 925
fix(auth): persist access_token on refresh to prevent token loss #869
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @FakerL, 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 a significant bug in the authentication system where refreshed access tokens were not being saved to persistent storage. The core problem was an oversight in the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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
This pull request fixes a bug where refreshed access tokens were not persisted for certain providers like iFlow. The fix involves removing access_token from the list of ignored fields when comparing token metadata for changes. This ensures that a change in the access token triggers a file write, persisting the new token. The change is correct and well-explained. I have one suggestion to make the fix more targeted to avoid potential side effects for other providers like Google OAuth.
Previously, metadataEqualIgnoringTimestamps() ignored access_token for all providers, which prevented refreshed tokens from being persisted to disk/database. This caused tokens to be lost on server restart for providers like iFlow. This change makes the behavior provider-specific: - Providers like gemini/gemini-cli that issue new tokens on every refresh and can re-fetch when needed will continue to ignore access_token (optimization) - Other providers like iFlow will now persist access_token changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
e602dcc to
33aa665
Compare
|
/gemini review |
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
This pull request correctly addresses a bug where refreshed access tokens were not being persisted for certain providers. The solution is to make the token comparison logic provider-aware, conditionally ignoring the access_token field. The change is well-described and effectively solves the issue. I've added one suggestion to improve the implementation's maintainability and adhere to Go idioms by replacing the map initialization with a switch statement, and also pointed out a potential architectural improvement for future consideration to better decouple components.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
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
This pull request effectively addresses a critical bug where refreshed access tokens were not being persisted, leading to authentication failures after a restart for providers like iFlow. The solution is well-targeted, introducing provider-specific logic to determine whether the access_token should be considered when checking for metadata changes. The change is clean and the pull request description is excellent, clearly explaining the root cause and the fix. I have one minor suggestion regarding future maintainability, but overall this is a great improvement.
…auto-update, request timeout, multi-candidate, auth persistence Applied features from upstream PRs: - PR router-for-me#878: Usage statistics persistence (SetPersistPath, LoadStatistics, SaveStatistics) - PR router-for-me#877: Codex plan type credential filename handling - PR router-for-me#868: Claude request cloaking utilities (obfuscation, fake user IDs) - PR router-for-me#715: Auto-update command for self-updating binary - PR router-for-me#860: Configurable request timeout with RequestTimeout config - PR router-for-me#879: Gemini multi-candidate support (n param -> candidateCount) - PR router-for-me#869: Auth token persistence for non-Google OAuth providers Fixed build issues: - Added applyPayloadConfig wrapper function - Added originalTranslated computation in claude/antigravity/codex executors - Fixed model registry hook methods - Removed duplicate SanitizeFunctionName - Fixed gemini_schema placeholder logic for nested object properties Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Cherry-picked from upstream PR router-for-me#869 Fixes token loss on server restart for providers requiring explicit token persistence
Summary
Root Cause
In
sdk/auth/filestore.go, themetadataEqualIgnoringTimestamps()function ignoredaccess_tokenfor all providers:This caused the
Save()function to skip writing the file when only the access token changed, resulting in:Solution
Made the behavior provider-specific by adding a
providerparameter tometadataEqualIgnoringTimestamps():geminiandgemini-clithat issue new tokens on every refresh and can re-fetch when needed will continue to ignoreaccess_token(optimization)iFlowwill now persistaccess_tokenchangesTest plan
�� Generated with Claude Code"