Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are several forms of authentication that web sites can use.</p> <ol> <li><p>HTTP Authentication. This where the browser pops up a window for you to enter your username and password. There are two mechanisms: basic and digest. There is an "Authorization" Header that comes along with the page that tells a browser (or a program using urllib2) what to do.</p> <p>In this case, you must configure your urlopener to provide the answers that the authorization header needs to see. You'll need to build either an <a href="http://docs.python.org/library/urllib2.html#urllib2.HTTPBasicAuthHandler" rel="nofollow noreferrer">HTTPBasicAuthHandler</a> or <a href="http://docs.python.org/library/urllib2.html#urllib2.HTTPDigestAuthHandler" rel="nofollow noreferrer">HTTPDigestAuthHandler</a>. </p> <p>AuthHandlers require a <a href="http://docs.python.org/library/urllib2.html#urllib2.HTTPPasswordMgr" rel="nofollow noreferrer">PasswordManager</a>. This password manager could have a hard-coded username and password (very common) or it could be clever and work out your Windows password from some Windows API.</p></li> <li><p>Application Authentication. This is where the web application directs you to a page with a form you fill in with a username and password. In this case, your Python program must use urllib2 to do a POST (a <a href="http://docs.python.org/library/urllib2.html#urllib2.urlopen" rel="nofollow noreferrer">request with data</a>) where the data is the form filled in properly. The reply to the post usually contains a cookie, which is what allows you further access. You don't need to worry much about the cookie, urllib2 handles this automatically.</p></li> </ol> <p>How do you know which you have? You dump the headers on the response. The response from urllib2.openurl includes all the headers (in <code>page.info()</code>) as well as the page content.</p> <p>Read <a href="https://stackoverflow.com/questions/720867/http-authentication-in-python">HTTP Authentication in Python</a></p> <p><a href="https://stackoverflow.com/questions/112768/how-would-one-log-into-a-phpbb3-forum-through-a-python-script-using-urllib-urlli">How would one log into a phpBB3 forum through a Python script using urllib, urllib2 and ClientCookie?</a></p> <p><a href="https://stackoverflow.com/questions/101742/how-do-you-access-an-authenticated-google-app-engine-service-from-a-non-web-pyt">How do you access an authenticated Google App Engine service from a (non-web) python client?</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload