fix(db oauth2): Improve OAuth2 flow (#39499)

This commit is contained in:
Vitor Avila
2026-04-21 11:54:52 -03:00
committed by GitHub
parent a222dab781
commit 191337e08d
7 changed files with 239 additions and 182 deletions

View File

@@ -368,6 +368,27 @@ class OAuth2RedirectError(SupersetErrorException):
)
class OAuth2TokenRefreshError(OAuth2RedirectError):
"""
Raised when an OAuth2 refresh token request fails with a 400/401/403 error.
The stored token is no longer valid and the user must re-authenticate.
Subclasses OAuth2RedirectError so that existing oauth2_exception checks
match it automatically, triggering start_oauth2_dance() via check_for_oauth2.
"""
def __init__(self, response_text: str) -> None:
SupersetErrorException.__init__(
self,
SupersetError(
message="OAuth2 token refresh failed, re-authentication required.",
error_type=SupersetErrorType.OAUTH2_REDIRECT,
level=ErrorLevel.WARNING,
extra={"error": response_text},
),
)
class OAuth2Error(SupersetErrorException):
"""
Exception for when OAuth2 goes wrong.