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

@@ -62,7 +62,11 @@ from superset import db
from superset.constants import QUERY_CANCEL_KEY, TimeGrain as TimeGrainConstants
from superset.databases.utils import get_table_metadata, make_url_safe
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
from superset.exceptions import OAuth2Error, OAuth2RedirectError
from superset.exceptions import (
OAuth2Error,
OAuth2RedirectError,
OAuth2TokenRefreshError,
)
from superset.key_value.types import JsonKeyValueCodec, KeyValueResource
from superset.sql.parse import (
BaseSQLStatement,
@@ -828,6 +832,8 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
if config["request_content_type"] == "data"
else requests.post(uri, json=req_body, timeout=timeout)
)
if response.status_code in (400, 401, 403):
raise OAuth2TokenRefreshError(response.text)
response.raise_for_status()
return response.json()