Skip to content

Comments

Add configurable refresh token support#38

Merged
dgellow merged 1 commit intomainfrom
sam/refresh-tokens
Jan 19, 2026
Merged

Add configurable refresh token support#38
dgellow merged 1 commit intomainfrom
sam/refresh-tokens

Conversation

@dgellow
Copy link
Member

@dgellow dgellow commented Jan 19, 2026

Adds refreshTokenTtl and refreshTokenScopes config options to control refresh token behavior. By default, refresh tokens are always issued (empty refreshTokenScopes) with a 30-day TTL, matching Linear's MCP server behavior. This improves UX for Claude Code users since tokens can now be silently refreshed instead of requiring re-authentication.

Also consolidates TTL defaults into config unmarshaling (single source of truth) and removes unused NewSession helper with hardcoded TTLs.

Adds refreshTokenTtl and refreshTokenScopes config options to control
refresh token behavior. By default, refresh tokens are always issued
(empty refreshTokenScopes) with a 30-day TTL, matching Linear's MCP
server behavior. This improves UX for Claude Code users since tokens
can now be silently refreshed instead of requiring re-authentication.

Also consolidates TTL defaults into config unmarshaling (single source
of truth) and removes unused NewSession helper with hardcoded TTLs.
@dgellow dgellow enabled auto-merge (squash) January 19, 2026 16:45
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @dgellow, 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 significantly enhances the authentication system by introducing configurable refresh token behavior. The primary goal is to improve the user experience by allowing client applications to silently refresh authentication tokens, thereby minimizing disruptive re-authentication prompts. This is achieved through new configuration options for refresh token lifespan and scopes, alongside a refactoring effort to centralize default TTL values and remove redundant code.

Highlights

  • Configurable Refresh Token Lifespan: Introduced refreshTokenTtl as a configurable option in the OAuth authentication configuration, allowing administrators to define the lifespan of refresh tokens. The default is set to 30 days, aligning with common practices for improved user experience.
  • Configurable Refresh Token Scopes: Added refreshTokenScopes to the OAuth configuration, providing control over the scopes associated with refresh tokens. By default, refresh tokens are always issued (empty refreshTokenScopes), which is beneficial for applications requiring silent token refreshing.
  • Improved User Experience: The new configurable refresh token support enables silent token refreshing for users, reducing the need for frequent re-authentication, particularly for applications like Claude Code.
  • Centralized TTL Defaults: Consolidated the default Time-To-Live (TTL) values for both access and refresh tokens within the configuration unmarshaling logic (unmarshal.go), establishing a single source of truth for these defaults.
  • Code Cleanup: Removed the unused NewSession helper function from internal/oauthsession/session.go, which previously contained hardcoded TTL values, further streamlining the codebase.
  • Configuration Validation: Added validation to ensure that both TokenTTL and RefreshTokenTTL configuration values are positive durations, preventing invalid configurations.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 introduces configurable refresh token TTL and scopes, which is a great improvement for user experience by allowing silent token refreshes. The changes are well-implemented, centralizing TTL defaults into the config unmarshaling process and removing unused code. My review includes one suggestion to improve maintainability by replacing a magic number for the default refresh token TTL with a constant.

}
o.RefreshTokenTTL = refreshTokenTTL
} else {
o.RefreshTokenTTL = 30 * 24 * time.Hour // Default: 30 days
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The magic number 30 * 24 * time.Hour is used as the default RefreshTokenTTL here and is also repeated in several test files (load_test.go, provider_test.go, auth_handlers_test.go, http_test.go). To improve maintainability and ensure consistency, consider defining this value as a constant in a central place, for example, as DefaultRefreshTokenTTL in the internal/config package. This would provide a single source of truth for this default value.

@dgellow dgellow merged commit 21929b3 into main Jan 19, 2026
1 of 2 checks passed
@dgellow dgellow deleted the sam/refresh-tokens branch January 19, 2026 16:50
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

Successfully merging this pull request may close these issues.

1 participant