superset icon indicating copy to clipboard operation
superset copied to clipboard

REST API

Open gsanchez10 opened this issue 10 years ago • 6 comments

I am trying to query an explore view from a cross origin. I don't have experience with python and tried using the labels: @has_access_api @cross_origin(allow_headers=['Content-Type'])

before the definition of the explore method but when I try to run the query it shows "http://example-domain.com:8080/login/" as the location header of the response. I guess there is a permissions problem I still have to figure out so I tried to trace where the app redirects to login with no luck.

how can I authenticate an access through an ajax call?

gsanchez10 avatar Jul 01 '16 22:07 gsanchez10

We installed cors support and enabled it in caravel following this instructions: pip install -U flask-cors

The following keys in caravel_config.py can be specified to configure CORS: ENABLE_CORS: True CORS_OPTIONS: without parameters

We want get the json from slices for example: https://example-domain.com:8088/caravel/explore/table/4/?slice_name=%25+RFC+Exitosos+-+1yr&y_axis_zero=y&resample_fillmethod=&show_brush=y&line_interpolation=linear&show_legend=y&resample_rule=&granularity_sqla=date{blablabla}e=kpm_measurements&contribution=false&time_grain_sqla=month&having=

Through ajax:

$.get(" https://example-domain.com:8088/caravel/explore/table/4/?slice_name=%25+RFC+Exitosos+-+1yr&y_axis_zero=y&resample_fillmethod=&show_brush=y&line_interpolation=linear&show_legend=y&resample_rule=&granularity_sqla=date{blablabla}e=kpm_measurements&contribution=false&time_grain_sqla=month&having=").done(function(response){ console.log(response); });

So we created a new view method with @cross_origin(allow_headers=['Content-Type'], supports_credentials=True) and without the @has_access decorator to test and it works, but we want to know if there is a native alternative to expose a service for a REST client.

gsanchez10 avatar Jul 04 '16 20:07 gsanchez10

+1

jxb45 avatar Jun 29 '17 15:06 jxb45

For future reference, I was able to get CORS working using the instructions here:

https://superset.incubator.apache.org/installation.html#cors

Which essentially just means to run this from your venv command line:

pip install superset[cors]

And to add the following line to your superset_config.py:

ENABLE_CORS = True

conroywhitney avatar Jul 07 '17 18:07 conroywhitney

Notice: this issue has been closed because it has been inactive for 289 days. Feel free to comment and request for this issue to be reopened.

mistercrunch avatar Apr 23 '18 17:04 mistercrunch

+1 Can we reopen the issue of exposing Superset resources via API? How do external applications authenticate requests for superset resources?

cKellyDesign avatar Nov 16 '18 16:11 cKellyDesign

activet

nileshkp1296 avatar Nov 16 '18 17:11 nileshkp1296