Make sure these boxes are checked before submitting your issue - thank you!
0.17.1
N/A
N/A
Sorry if this has been answered somewhere else, but is there any documentation on how to authenticate through the REST API?
Specifically, I'd like to be able to return JSON from the /superset/explore_json/
endpoint (copied from the UI slice view) using cURL (or something similar) but I get the following response when I do:
{
"message": "Access is Denied",
"severity": "danger"
}
Thanks
This is how we do it in the unit tests:
https://github.com/airbnb/superset/blob/master/tests/base_tests.py#L127
But that may vary depending on the type of authentication you use.
Hey @amancevice did you figure this out? I have this exact use case and was wondering if you solve it.
Thanks!
@slarrain I did not -- gave up & moved on to other things. Sorry!
For those still looking for some kind of solution - the following example seems to work:
import requests
from bs4 import BeautifulSoup
# set up session for auth
s = requests.Session()
login_form = s.post("http://my_server/login")
# get Cross-Site Request Forgery protection token
soup = BeautifulSoup(login_form.text, 'html.parser')
csrf_token = soup.find('input',{'id':'csrf_token'})['value']
# login the given session
s.post('http://my_server/login/',data=dict(username='admin', password='my_passwd',csrf_token=csrf_token))
# run API call
print(s.get('http://my_server/users/api').text)
Is there a documentation of the rest api ?
The part we get for free on modelviews through FAB is documented here:
https://github.com/dpgaspar/Flask-AppBuilder/blob/master/docs/quickhowto.rst#exposed-methods
i need authentication by using json web tokens
For those still looking for some kind of solution - the following example seems to work:
import requests from bs4 import BeautifulSoup # set up session for auth s = requests.Session() login_form = s.post("http://my_server/login") # get Cross-Site Request Forgery protection token soup = BeautifulSoup(login_form.text, 'html.parser') csrf_token = soup.find('input',{'id':'csrf_token'})['value'] # login the given session s.post('http://my_server/login/',data=dict(username='admin', password='my_passwd',csrf_token=csrf_token)) # run API call print(s.get('http://my_server/users/api').text)
I had to change login_form = s.post("http://my_server/login") to login_form = s.get("http://my_server/login")
for this to work. thanks!
Most helpful comment
For those still looking for some kind of solution - the following example seems to work: