Python login script to CSRF protected web site -
i trying create simple login script rol.redhat.com web site. here example:
import sys import requests url = 'https://rol.redhat.com/rol/rhz/login' # csrf token client = requests.session() client.get(url) token = client.cookies['csrftoken'] # login login_data = dict(username='username', password='password',csrftoken=token) r = client.post(url, data=login_data, headers=dict(referer=url)) print r.status_code print r.text but receiving this:
403
(...)
forbidden (403)
csrf verification failed. request aborted.
(...)
what wrong in script?
Comments
Post a Comment