Skip to content

Instantly share code, notes, and snippets.

@uasi
Created August 28, 2008 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uasi/7709 to your computer and use it in GitHub Desktop.
Save uasi/7709 to your computer and use it in GitHub Desktop.
import urllib2
# Add basic authentication handler to urllib2
mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
mgr.add_password(None, 'example.com', 'username', 'password')
auth_handler = urllib2.HTTPBasicAuthHandler(mgr)
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment