mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-26 21:54:50 -05:00
[PR #22652] [CLOSED] fix: add configurable access_type and prompt for Google OAuth refresh… #26798
Reference in New Issue
Block a user
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22652
Author: @ethan-l-geotab
Created: 3/13/2026
Status: ❌ Closed
Base:
dev← Head:fix/google-oauth-refresh-token-dev📝 Commits (1)
7bc28c6fix: add configurable access_type and prompt for Google OAuth refresh tokens📊 Changes
1 file changed (+20 additions, -0 deletions)
View changed files
📝
backend/open_webui/config.py(+20 -0)📄 Description
Pull Request Checklist
devbranch.GOOGLE_OAUTH_SCOPEandOAUTH_TIMEOUTconfigurations.dev.Changelog Entry
Description
Without
access_type=offlinein the Google OAuth authorization request, Google only returns a short-lived access token (1 hour) with norefresh_token. The existing refresh logic inOAuthManager._perform_token_refresh()always bails at theif not token_data.get("refresh_token")check because no refresh token is ever stored. After ~55 minutes, the OAuth session is silently deleted from the database, breaking any functionality relying on__oauth_token__(tools, MCP servers withsystem_oauthauth) while the user's Open WebUI session remains active.This is a Google-specific issue: Google requires
access_type=offline(a proprietary parameter not part of the OIDC spec) to issue refresh tokens. The OIDC discovery document gives no hint about this parameter, so authlib cannot add it automatically.This PR adds two new environment variables that populate
authorize_paramsin the Google OAuth client registration, enabling operators to opt in to refresh token support.Added
GOOGLE_OAUTH_ACCESS_TYPEenvironment variable (default:"") — set to"offline"to request refresh tokens from GoogleGOOGLE_OAUTH_PROMPTenvironment variable (default:"") — set to"consent"to force re-consent and guarantee a fresh refresh token for users who previously authorized the appChanged
google_oauth_register()inconfig.pynow conditionally includesauthorize_paramswhen either env var is set (empty values are filtered out)Deprecated
Removed
Fixed
GOOGLE_OAUTH_ACCESS_TYPE=offlineis configuredOAuthManager._perform_token_refresh()) now functions as intended for Google OAuthSecurity
oauth_sessiontable, consistent with how all other OAuth tokens are storedBreaking Changes
Additional Information
offline? To avoid changing behavior for existing deployments. Operators can opt in by settingGOOGLE_OAUTH_ACCESS_TYPE=offline.promptseparate? Google only returns a refresh token on the first authorization. For users who previously authorized the app,prompt=consentforces re-consent. This can be set temporarily and removed once all users have re-authenticated.refresh_tokenstored inoauth_sessiontable after login"Successfully refreshed token for session ...")Screenshots or Videos
N/A — backend-only change with no UI impact.
Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.