question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to authenticate with REST API

See original GitHub issue

Make sure these boxes are checked before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if any
  • I have reproduced the issue with at least the latest released version of superset
  • I have checked the issue tracker for the same issue and I haven’t found one similar

Superset version

0.17.1

Expected results

N/A

Actual results

N/A

Steps to reproduce

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:27 (10 by maintainers)

github_iconTop GitHub Comments

21reactions
andrewsalicommented, Jan 17, 2018

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)
7reactions
mistercrunchcommented, Mar 28, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best practices for REST API security: Authentication and ...
Best practices for REST API security: Authentication and authorization · Always use TLS · Use OAuth2 for single sign on (SSO) with OpenID...
Read more >
4 Most Used REST API Authentication Methods
4 Most Used REST API Authentication Methods · Basic · Authorization Header · access token: sent like an API key, it allows the...
Read more >
5 fundamental strategies for REST API authentication
There are various authentication methods for REST APIs, ranging from basic credentials and token encryption to complex, multilayered access ...
Read more >
REST API Authentication - Stack Overflow
In a nutshell, let the client send a username and password with every request using HTTP Basic Auth (over SSL!), or authenticate once...
Read more >
REST API authentication - Oracle Commerce
REST API authentication · The response includes an access token to use in subsequent requests. Each API you log into returns a separate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found