How to superset login using curl command?

2,198 views
Skip to first unread message

mike

unread,
May 24, 2017, 11:17:37 AM5/24/17
to airbnb_superset
Hi.
I am going to use the curl command to get a list of superset dashboards.
So first I have to login from superset.
But I can not login well.

How do I handle login with the curl command?

Below is the login curl command.

```
curl -i --data 'userName=admin&password=123456&csrf_token=ImEwODdjNzc4YjFmMGIyMjk5YTY3Y2YxYzNlYTA0YTc1MjY1NDBkYTIi.DAHvaA.TCOgcoCQ6IVkpfIvm2ABjzfXYic' -X POST "http://{supersetURL}/login/"

HTTP/1.1 400 BAD REQUEST
Server: gunicorn/19.6.0
Date: Wed, 24 May 2017 15:10:41 GMT
Connection: close
Content-Type: text/html
Content-Length: 150

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>The CSRF session token is missing.</p>
```

Help.
Thanks.

Maxime Beauchemin

unread,
May 30, 2017, 12:44:55 PM5/30/17
to airbnb_superset
Currently you'll have to mimic a session and somehow retrieve a token first, perhaps from the login page. We have yet to take a look at how classic REST apis deal with CSRF and make the appropriate changes.

You can also turn CSRF off, depending on the constraints you have in your environment.

Max

Maxime Beauchemin

unread,
May 30, 2017, 12:46:49 PM5/30/17
to airbnb_superset
Also note that the solution depends on the authentication scheme you have set up in your environment. For example at Airbnb we use "REMOTE_USER" so it's a matter of putting in the right headers and hit the endpoint from behind the reverse proxy.

Maxime Beauchemin

unread,
May 30, 2017, 5:54:25 PM5/30/17
to airbnb_superset
I had forgotten you can get a token with an API call here: `/superset/csrf_token/`
Reply all
Reply to author
Forward
0 new messages