Summary (@Freek Wiekmeijer, @gtalarico) other's answer:
authentication
, then can access, otherwise 405 Not Allowed
authentication
=grant access
method are:
cookie
auth header
Basic xxx
Authorization xxx
cookie
in requests
to authcookie
in headers
cookie
by requests
's
session
to auto manage cookiesresponse.cookies
to manually set cookiesrequests
's session
auto manage cookiescurSession = requests.Session()
# all cookies received will be stored in the session object
payload={'username': "yourName",'password': "yourPassword"}
curSession.post(firstUrl, data=payload)
# internally return your expected cookies, can use for following auth
# internally use previously generated cookies, can access the resources
curSession.get(secondUrl)
curSession.get(thirdUrl)
requests
's response.cookies
payload={'username': "yourName",'password': "yourPassword"}
resp1 = requests.post(firstUrl, data=payload)
# manually pass previously returned cookies into following request
resp2 = requests.get(secondUrl, cookies= resp1.cookies)
resp3 = requests.get(thirdUrl, cookies= resp2.cookies)