'Cannot autheticate on API. Get the tokens (JWT and csrf) but all responses are "401" in Apache Sueperset API
I cannot use the API successfully for any request (except to get the security tokens); I'm always getting "Response 401" for any request, even if I use the tokens.
How to reproduce the bug:
On the docker container where the superset is running:
import requests
session = requests.session()
jwt_token = session.post(
url='http://localhost:8088/api/v1/security/login',
json={
"username": "admin",
"password": "admin",
"refresh": False,
"provider": "db"
}
).json()["access_token"]
csrf_token = session.get(
url='http://localhost:8088/api/v1/security/csrf_token/',
headers={
'Authorization': f'Bearer {jwt_token}',
}
).json()["result"]
headers = {
'accept': 'application/json',
'Authorization': f'Bearer {jwt_token}',
'X-CSRFToken': csrf_token,
}
#using api/v1/me as a test
response = requests.get('http://localhost:8088/api/v1/me', headers=headers)
session.close()
Expected results
{"result": {"email": "[email protected]","first_name": "Superset","id": 1,"is_active": true,"is_anonymous": false,"last_name": "Admin","username": "admin"}}
Actual results
response
<Response [401]>
Environment
- superset version: v1.0.0
- python version: Python 3.8.12
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
