django.utils.six.moves.urllib.request.HTTPBasicAuthHandler.auth_header

Here are the examples of the python api django.utils.six.moves.urllib.request.HTTPBasicAuthHandler.auth_header taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

Example 1

Project: reviewboard
Source File: service.py
View license
    def _build_request(self, url, body=None, headers={}, username=None,
                       password=None, method='GET'):
        """Build a URLRequest object, including HTTP Basic auth"""
        r = URLRequest(url, body, headers, method=method)

        if username is not None and password is not None:
            auth_key = username + ':' + password
            r.add_header(HTTPBasicAuthHandler.auth_header,
                         'Basic %s' %
                         base64.b64encode(auth_key.encode('utf-8')))

        return r