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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to