buremba opened a new issue #16398:
URL: https://github.com/apache/superset/issues/16398
### Expected results
`POST /api/v1/database` endpoint should work because it's in the
documentation.
### Actual results
When I use the Swagger client embedded into the application (`/swagger/v1`),
the API throws the following exception:
```
The CSRF token is missing.
```
Here is a snippet that reproduces the same issue as well:
```
token_request =
requests.get("{}/api/v1/security/csrf_token".format(self.superset_url),
headers={'Authorization': 'Bearer
{}'.format(self.current_access_token)})
if token_request.status_code != 200:
raise Exception("Unable to get CSRF token:
{}".format(token_request.text))
csrf_token = token_request.json().get('result')
r = requests.post("{}/api/v1/database".format(self.superset_url),
json={
"allow_csv_upload": False,
"allow_ctas": True,
"allow_cvas": False,
"allow_dml": False,
"allow_multi_schema_metadata_fetch": True,
"allow_run_async": True,
"database_name": database_name,
"expose_in_sqllab": True,
"sqlalchemy_uri": "presto://.."
},
headers={'Authorization': 'Bearer
{}'.format(self.current_access_token), "X-CSRFToken": csrf_token})
```
#### Screenshots
<img width="1336" alt="CleanShot 2021-08-23 at 16 39 28@2x"
src="https://user-images.githubusercontent.com/82745/130457225-9266547a-5505-4391-a517-a3bc0861e77c.png">
Environment:
superset version: superset version `1.2.0`
python version: python --version: `python-3.7.10`
node.js version: node -v: not relevant
### Checklist
Make sure to follow these steps before submitting your issue - thank you!
- [x] I have checked the superset logs for python stacktraces and included
it here as text if there are any.
- [x] I have reproduced the issue with at least the latest released version
of superset.
- [x] I have checked the issue tracker for the same issue and I haven't
found one similar.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]