Skip to content

Instantly share code, notes, and snippets.

@jhuss
Created December 15, 2014 04:31
Show Gist options
  • Save jhuss/364547cdf21397d7bad0 to your computer and use it in GitHub Desktop.
Save jhuss/364547cdf21397d7bad0 to your computer and use it in GitHub Desktop.
Basic Authorization Request
from base64 import b64encode
from urllib2 import Request, urlopen
request = Request(url)
base64string = b64encode(b'{0}:{1}'.format(self.username_api, self.password_api)).decode("ascii")
request.add_header('Authorization', b'Basic {0}'.format(base64string))
result = urlopen(request)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment