diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx index e4f27046666..c892816c387 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx @@ -551,6 +551,10 @@ const DatabaseModal: FunctionComponent = ({ }); // cast the new encrypted extra object into a string dbToUpdate.encrypted_extra = JSON.stringify(additionalEncryptedExtra); + // this needs to be added by default to gsheets + if (dbToUpdate.engine === 'gsheets') { + dbToUpdate.impersonate_user = true; + } } if (dbToUpdate?.parameters?.catalog) { diff --git a/superset/db_engine_specs/gsheets.py b/superset/db_engine_specs/gsheets.py index 8136c1754b7..3889e990795 100644 --- a/superset/db_engine_specs/gsheets.py +++ b/superset/db_engine_specs/gsheets.py @@ -153,9 +153,12 @@ class GSheetsEngineSpec(SqliteEngineSpec): cls, parameters: GSheetsParametersType, ) -> List[SupersetError]: errors: List[SupersetError] = [] - encrypted_credentials = json.loads( - parameters.get("service_account_info") or "{}" - ) + encrypted_credentials = parameters.get("service_account_info") or "{}" + + # On create the encrypted credentials are a string, + # at all other times they are a dict + if isinstance(encrypted_credentials, str): + encrypted_credentials = json.loads(encrypted_credentials) table_catalog = parameters.get("catalog", {})