mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
fix(db oauth2): Improve OAuth2 flow (#39499)
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user