You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/03/27 13:47:33 UTC

[GitHub] [incubator-superset] prgx-mrodri01 commented on issue #2488: How to authenticate with REST API

prgx-mrodri01 commented on issue #2488: How to authenticate with REST API
URL: https://github.com/apache/incubator-superset/issues/2488#issuecomment-605009899
 
 
   > 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)
   > ```
   
   I had to change login_form = s.post("http://my_server/login") to login_form = s.get("http://my_server/login")
   for this to work. thanks! 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org