[Python] Using Basic HTTP Authentication

To use urllib2 to access content that requires HTTP authentication, you need to create an OpenerDirector with a HTTPBasicAuthHandler. With HTTPBasicAuthHandler, add the authentication details by calling its add_password method. It takes in four parameters – realm, uri, user and passwd.
Read more of this post