hi,
might be useful someday to someone.. the superset REST API has a
swagger:
https://superset.apache.org/docs/api/
but to use the API, one needs to authenticate first..
i've had it working with a small script (vastly inspired by
https://github.com/apache/superset/issues/20546), using the 'admin' user
created by superset fab create-admin (i havent found how to make it use
the header-based authentication):
set USER/PASS/PORT env vars with the details about your own superset
installation:
USER=admin
PASS=admin
PORT=5590
get a jwt token:
AUTH=$(curl -s -d
'{"password":"'$PASS'","refresh":false,"provider":"db","username":"'$USER'"}'
-XPOST -HAccept:application/json -HContent-type:application/json
http://localhost:$PORT/superset/api/v1/security/login | jq -r .access_token)
with that token, get a CSRF token:
CSRF=$(curl -s -HAuthorization:\"Bearer $AUTH\"
http://localhost:$PORT/superset/api/v1/security/csrf_token/ | jq -r .result)
and use both tokens to query the API, here i get details about the first
defined database:
curl -s -H Authorization:"Bearer $AUTH" -HX-CSRF-Token:$CSRF
http://localhost:$PORT/superset/api/v1/database/1
this returns json, that you can also parse with jq:
$sh superset-api.sh | jq .result.database_name
"rtge"
some queries (eg /me/ or /me/roles/) return a 403, but others do seem to
work.
HTH!
--
Landry Breuil