mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 19:38:46 -05:00
[PR #22357] [CLOSED] fix: add support for scope in OAuth refresh token request #65484
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22357
Author: @pedro-inf-custodio
Created: 3/7/2026
Status: ❌ Closed
Base:
main← Head:fix/add-scope-refresh-token-oauth📝 Commits (10+)
ca2aaf0fix: ot terminala36692bMerge pull request #22231 from ShirasawaSama/patch-105af24b3fix: Implement archive chat handler in Chat page navbar (#22229)7d45459fix: keep save button spinner inline (#22227)ad27535i18n(fr-FR): complete French translation pass (#22200)6e43861feat: prioritize in-group members in sorting (#22211)890949afeat: add DOCX/XLSX/PPTX file previewe08341denh: ot portsf962baefeat: improve XLSX preview + add code syntax highlighting627b063refac📊 Changes
118 files changed (+5248 additions, -824 deletions)
View changed files
📝
.github/pull_request_template.md(+3 -1)📝
backend/open_webui/config.py(+1 -1)📝
backend/open_webui/env.py(+10 -0)📝
backend/open_webui/internal/db.py(+24 -5)📝
backend/open_webui/main.py(+44 -38)📝
backend/open_webui/models/functions.py(+22 -0)📝
backend/open_webui/routers/retrieval.py(+27 -24)📝
backend/open_webui/routers/skills.py(+1 -1)📝
backend/open_webui/routers/tools.py(+1 -1)📝
backend/open_webui/socket/main.py(+2 -0)📝
backend/open_webui/utils/middleware.py(+34 -23)📝
backend/open_webui/utils/models.py(+5 -1)📝
backend/open_webui/utils/oauth.py(+12 -0)📝
backend/open_webui/utils/telemetry/instrumentors.py(+2 -0)📝
backend/open_webui/utils/telemetry/metrics.py(+2 -2)📝
backend/requirements-min.txt(+1 -0)📝
backend/requirements.txt(+2 -0)📝
package-lock.json(+528 -3)📝
package.json(+3 -0)📝
src/lib/apis/terminal/index.ts(+101 -0)...and 80 more files
📄 Description
Contributor License Agreement (CLA)
By submitting this pull request, I certify that I have the right to submit this code and that it complies with the project's licensing requirements.
Description
This PR fixes an issue where the refresh token request for Microsoft OAuth was failing with error
AADSTS90009. Previously, the refresh payload only included thegrant_type,refresh_token,client_id, and optionallyclient_secret.Azure AD requires the scope (or resource) to be explicitly provided when refreshing a token. Without it, Azure interprets the request as “the application is requesting a token for itself,” which triggers the 400 error:
Changes
MICROSOFT_OAUTH_SCOPE._perform_token_refreshto include this scope when refreshing tokens.Root Cause
scopecaused Azure to treat the request as self-targeted, resulting inAADSTS90009.Logs Before Fix
Logs After Fix
Environment Variables
MICROSOFT_OAUTH_SCOPE(required) – the custom scope for token requests.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.