billdestein commented on issue #32315: URL: https://github.com/apache/superset/issues/32315#issuecomment-2671213795
Hi Haineber, yes IAM works as well. My final code for IAM is pasted below. It seems that the IAM approach requires legitimate looking Cookie and X-CSRFToken headers. So I opened my browser network trace, and used the Superset UI to create a Redshift Serverless database connection, and I stole the headers from the v1/database response. Can you think of a more automated way to get Cookie and CSRF headers? Thanks! def create_redshift_database_connection(self): credentials = self.payload['credentials'] account_id = credentials['accountId'] password = 'ProductPassword123' port = self.payload['port'] user = 'ProductUser123' work_group = 'product' headers = { 'Accept': 'application/json', 'Cookie': 'session=...', 'Content-Type': 'application/json', 'X-CSRFToken': '...' } extra = { "engine_params": { "connect_args": { "iam": True, "is_serverless": True, "serverless_acct_id": account_id, "serverless_work_group": work_group, "database": "dev" } } } data = { "sqlalchemy_uri": f'redshift+redshift_connector://{user}:{password}@{work_group}.{account_id}.us-west-2.redshift-serverless.amazonaws.com:5439/dev', "database_name":"Amazon Redshift", "extra": json.dumps(extra), "masked_encrypted_extra":"" } url = f'http://127.0.0.1:{port}/api/v1/database/' response = requests.post(url, json = data, headers = headers) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org