Bug description
Bug summary
CSRF Session token is missing when calling the create dataset endpoint via the Python API after apparently successful login and csrf token retrieval. /api/v1/me/ returns 401 error but other endpoints such as copy dashboard or create role work just fine with the same requests.Session object.
Expected behavior
GET /api/v1/me/ should return the authenticated user information.
POST /api/v1/dataset/ should create the requested dataset successfully.
Actual behavior
GET /api/v1/me/ returns 401 {"message":"Not authorized"}.
POST /api/v1/dataset/ returns:
400, {"errors": [{"message": "400 Bad Request: The CSRF session token is missing.", "error_type": "GENERIC_BACKEND_ERROR", "level": "error", "extra": {"issue_codes": [{"code": 1011, "message": "Issue 1011 - Superset encountered an unexpected error."}]}}]}
Steps to reproduce
- Login via the login endpoint
- Update the access token header
- Obtain the csrf token
- Update the csrf token header
- Make a get request to /api/v1/me/
- Make a post request to /api/v1/dataset/
Python code / request example
r_session = requests.Session()
r_session.headers.update({
'Accept': 'application/json',
'Content-Type': 'application/json',
'Referer': base_url
})
r = r_session.post(f"{base_url}/api/v1/security/login", json=login_data)
if r.status_code != 200:
raise Exception(f"Failed to login: {r.status_code} {r.text}")
access_token = r.json()["access_token"]
r_session.headers.update({'Authorization': f"Bearer {access_token}"})
r = r_session.get(f"{base_url}/api/v1/security/csrf_token/")
if r.status_code != 200:
raise Exception(f"Failed to get CSRF token: {r.status_code} {r.text}")
csrf_token = r.json()["result"]
r_session.headers.update({'X-CSRFToken': csrf_token})
r = r_session.get(base_url + f"/api/v1/me/", headers=r_session.headers)
print(f"Status: {r.status_code}")
print(f"Response: {r.text}")
r = r_session.post(
base_url + f"/api/v1/dataset/"
, json={
"database": database,
"table_name": table_name,
"schema": schema
}
)
if r.status_code == 201:
logging.info(f"Dataset '{table_name}' has been created successfully in database '{database}' and schema '{schema}'")
return r.json()["id"]
else:
raise ValueError(f"Error creating dataset '{table_name}' in database '{database}' and schema '{schema}': {r.status_code}, {r.text}")
Tracebacks and returns
The Python tracebacks observed in the logs show:
10.31.232.26 - - [17/Apr/2026:11:25:57 +0000] "POST /api/v1/security/login HTTP/1.1" 200 487 URL "python-requests/2.33.1"
10.31.232.26 - - [17/Apr/2026:11:25:57 +0000] "GET /api/v1/security/csrf_token/ HTTP/1.1" 200 105 URL "python-requests/2.33.1"
10.31.232.26 - - [17/Apr/2026:11:25:57 +0000] "GET /api/v1/me/ HTTP/1.1" 401 29 URL "python-requests/2.33.1"
The POST request to the dataset seems to fail before it is even really made and so it does not show in the logs, however, the ValueError raised shows:
400, {"errors": [{"message": "400 Bad Request: The CSRF session token is missing.", "error_type": "GENERIC_BACKEND_ERROR", "level": "error", "extra": {"issue_codes": [{"code": 1011, "message": "Issue 1011 - Superset encountered an unexpected error."}]}}]}
Screenshots/recordings
No response
Superset version
6.0.0
Python version
3.11
Node version
I don't know
Browser
Chrome
Additional context
I have tried completely deleting the Public role to avoid possible known conflicts with this role and the Admin Role in api requests but it made no difference.
Checklist
Bug description
Bug summary
CSRF Session token is missing when calling the create dataset endpoint via the Python API after apparently successful login and csrf token retrieval. /api/v1/me/ returns 401 error but other endpoints such as copy dashboard or create role work just fine with the same requests.Session object.
Expected behavior
GET /api/v1/me/should return the authenticated user information.POST /api/v1/dataset/should create the requested dataset successfully.Actual behavior
GET /api/v1/me/returns401 {"message":"Not authorized"}.POST /api/v1/dataset/returns:Steps to reproduce
Python code / request example
Tracebacks and returns
The Python tracebacks observed in the logs show:
10.31.232.26 - - [17/Apr/2026:11:25:57 +0000] "POST /api/v1/security/login HTTP/1.1" 200 487 URL "python-requests/2.33.1"
10.31.232.26 - - [17/Apr/2026:11:25:57 +0000] "GET /api/v1/security/csrf_token/ HTTP/1.1" 200 105 URL "python-requests/2.33.1"
10.31.232.26 - - [17/Apr/2026:11:25:57 +0000] "GET /api/v1/me/ HTTP/1.1" 401 29 URL "python-requests/2.33.1"
The POST request to the dataset seems to fail before it is even really made and so it does not show in the logs, however, the ValueError raised shows:
400, {"errors": [{"message": "400 Bad Request: The CSRF session token is missing.", "error_type": "GENERIC_BACKEND_ERROR", "level": "error", "extra": {"issue_codes": [{"code": 1011, "message": "Issue 1011 - Superset encountered an unexpected error."}]}}]}
Screenshots/recordings
No response
Superset version
6.0.0
Python version
3.11
Node version
I don't know
Browser
Chrome
Additional context
I have tried completely deleting the Public role to avoid possible known conflicts with this role and the Admin Role in api requests but it made no difference.
Checklist