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 2019/12/16 23:55:44 UTC

[GitHub] [incubator-superset] DungLai removed a comment on issue #2488: How to authenticate with REST API

DungLai removed a comment on issue #2488: How to authenticate with REST API
URL: https://github.com/apache/incubator-superset/issues/2488#issuecomment-565895492
 
 
   > 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)
   > ```
   
   `csrf_token = soup.find('input',{'id':'csrf_token'})['value']` gave me this error:
   
   `TypeError: 'NoneType' object is not subscriptable`
   
   Not sure what I'm missing 

----------------------------------------------------------------
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