Building Superset REST API Connector with Bearer Token Authentication in Airbyte UI

Summary

The user is looking for guidance on how to build a Superset REST API connector with bearer token authentication in Airbyte UI. They have provided Python code for reference that includes obtaining a bearer token through username and password. The user is seeking ideas or a simple solution to achieve this.


Question

Hello guys i am trying to build the superset rest api as a connector, it has bearer token authentication where it will get the bearer token through username and password and attaching python code for the reference . how can i achieve this through ui in airbyte. can anyone please guide me on this just an idea on how to achieve this or any simple solution
import requests
import json

def get_dataset_data(dataset_id):
base_url = “base_url”

# 1. Login to get token
login_url = f"{base_url}/api/v1/security/login"
login_data = {
    "username": "username",
    "password": "password",
    "provider": "db"
}

session = requests.Session()
login_response = <http://session.post|session.post>(login_url, json=login_data)
token = login_response.json().get('access_token')

# 2. Setup headers
headers = {
    'Authorization': f'Bearer {token}',
    'Content-Type': 'application/json'
}

# 3. Simple query payload for all data from dataset
# 2. Modified payload with required query parameters
payload = {
    "datasource": {
        "id": dataset_id,
        "type": "table"
    },
    "force": False,
    "queries": [{
        "columns": ["created_at"],  # Select all columns
        # "metrics": ["count(*)"],  # At least one metric is usually required
        "row_limit": 1000,
        "filters": [],
        "orderby": []
    }]
}

# 4. Make the request
response = <http://requests.post|requests.post>(
    f"{base_url}/api/v1/chart/data",
    headers=headers,
    json=payload
)

print("Response:", json.dumps(response.json(), indent=2))
return response.json()

Usage

dataset_id = 60 # Replace with your actual dataset ID
result = get_dataset_data(dataset_id)
Can anyone help me with this



This topic has been created from a Slack thread to give it more visibility.
It will be on Read-Only mode here. Click here if you want
to access the original thread.

Join the conversation on Slack

["superset-rest-api", "connector", "bearer-token-authentication", "python-code", "airbyte-ui"]