Superset as a data provider

Superset provides the following endpoint for slice (charts) data,

@expose('/slice_json/<slice_id>')
def slice_json(self, slice_id):
    form_data, slc = self.get_form_data(slice_id, use_slice_data=True)
    datasource_type = slc.datasource.type
    datasource_id = slc.datasource.id

    return self.generate_json(datasource_type=datasource_type, datasource_id=datasource_id, 
form_data=form_data)

which takes in a sliceID as an argument and returns a json object for the given chart. The json returned contains a lot of information such as the data in the slice, the query used to create it, the filters available in the slice and the datasource.

In order to get authorization for this access, since authentication is done using openlmis OAuth, we can a user's access token. The request would be

curl -s -L --cookie-jar "cookies.txt" -H "custon_api_token:<access_token>" "https://superset.ona.io/oauth-authorized/openlmis"

The above request sends a user's access token to superset and in return it gets a session cookie which is stored in the cookies.txt file. The cookie can then be used to get data from superset like

curl -s -L -b "cookies.txt" "http://superset.ona.io/superset/slice_json/<slide-id>"

The user would have to have the right role/permissions in order to receive the data that is being accessed.

OpenLMIS: the global initiative for powerful LMIS software