Setup headers for authentication request.
761803
def get_headers(self):
        """"""

        try:
            return {
                'X-Auth-User': self.job_args['os_user'],
                'X-Auth-Key': self.job_args['os_apikey']
            }
        except KeyError as exp:
            raise exceptions.AuthenticationProblem(
                'Missing Credentials. Error: %s',
                exp
            )
990960
def authenticate_user(self, response, **kwargs):
        """"""

        host = urlparse(response.url).hostname

        try:
            auth_header = self.generate_request_header(response, host)
        except KerberosExchangeError:
            # GSS Failure, return existing response
            return response

        log.debug("authenticate_user(): Authorization header: {0}".format(
            auth_header))
        response.request.headers['Authorization'] = auth_header

        # Consume the content so we can reuse the connection for the next
        # request.
        response.content
        response.raw.release_conn()

        _r = response.connection.send(response.request, **kwargs)
        _r.history.append(response)

        log.debug("authenticate_user(): returning {0}".format(_r))
        return _r
561395
protected function setupHttpClientSettings()
    {
        $this->httpClient->setDefaultOption('exceptions', false);
        $this->httpClient->setDefaultOption('timeout', $this->options['timeout']);
        $this->httpClient->setDefaultOption('connect_timeout', $this->options['connect_timeout']);

        $this->httpClient->setDefaultOption('headers', [
            'Content-Type' => 'application/json',
            'Authorization' => $this->auth->generateAuthorization()
        ]);
    }
934475
def add_signing_headers(verb, path, request)
      log.info "Adding signed header authentication..."

      authentication = Authentication.from_options(
        user: client,
        key:  key,
        verb: verb,
        path: path,
        body: request.body || request.body_stream,
      )

      authentication.headers.each do |key, value|
        log.debug "#{key}: #{value}"
        request[key] = value
      end

      if request.body_stream
        request.body_stream.rewind
      end
    end
1372892
def _default_request_kwargs(self):
        """"""
        defaults = copy.deepcopy(super(Acls, self)._default_request_kwargs)
        defaults.setdefault('headers', {}).update({
            'X-Auth-Token': self._client.auth._token
        })
        return defaults
866247
protected function _setChallengeHeaders()
    {
        if ($this->isProxyAuth()) {
            $statusCode = 407;
            $headerName = 'Proxy-Authenticate';
        } else {
            $statusCode = 401;
            $headerName = 'WWW-Authenticate';
        }

        // Send a challenge in each acceptable authentication scheme
        $this->response()->setStatusCode($statusCode);

        $headers = $this->response()->headers();
        $headers->insert(FactoryHttpHeader::of(array(
                $headerName => $this->_getAuthenticateChallengeHeader())
        ));

        // $headers->insert(FactoryHttpHeader::of( array('Authorization' => 'deleted')) );
    }
13361
def headers_to_include_from_request(curr_request):
    '''
        
    '''
    return {
        h: v for h, v in curr_request.META.items() if h in _settings.HEADERS_TO_INCLUDE}
379538
def generate_headers(self, token):
        """"""
        headers = {}
        token = self.encode_token(token)
        if self.config["header"]:
            headers[self.config["header"]] = token
        if self.config["cookie"]:
            headers["Set-Cookie"] = dump_cookie(
                self.config["cookie"], token, httponly=True,
                max_age=self.config["expiration"]
            )
        return headers
163114
def get_headers(server):
    """"""
    try:
        response = requests.head(
            server, allow_redirects=False, verify=False, timeout=5)
    except requests.exceptions.ConnectionError:
        return False

    return dict(response.headers)
944321
private static function headers() {
        if (empty(self::$config['httpHeaders'])) {
            return;
        }

        $response = self::$config['httpContext']->getResponse();
        $response->setHeaders(self::$config['httpHeaders']);
    }
774452
private void addHeaders(HttpRequest request, Map<String, String> headers) {
		for (Map.Entry<String, String> key : headers.entrySet()) {
			request.addHeader(key.getKey(), key.getValue());
		}
	}
473221
def _build_put_headers(self, robj, if_none_match=False):
        """"""

        # Construct the headers...
        if robj.charset is not None:
            content_type = ('%s; charset="%s"' %
                            (robj.content_type, robj.charset))
        else:
            content_type = robj.content_type

        headers = MultiDict({'Content-Type': content_type,
                             'X-Riak-ClientId': self._client_id})

        # Add the vclock if it exists...
        if robj.vclock is not None:
            headers['X-Riak-Vclock'] = robj.vclock.encode('base64')

        # Create the header from metadata
        self._add_links_for_riak_object(robj, headers)

        for key in robj.usermeta.keys():
            headers['X-Riak-Meta-%s' % key] = robj.usermeta[key]

        for field, value in robj.indexes:
            key = 'X-Riak-Index-%s' % field
            if key in headers:
                headers[key] += ", " + str(value)
            else:
                headers[key] = str(value)

        if if_none_match:
            headers['If-None-Match'] = '*'

        return headers
711477
def _authenticate(self):
        """"""
        self.cleanup_headers()
        url = LOGIN_ENDPOINT
        data = self.query(
            url,
            method='POST',
            extra_params={
                'email': self.__username,
                'password': self.__password
            })

        if isinstance(data, dict) and data.get('success'):
            data = data.get('data')
            self.authenticated = data.get('authenticated')
            self.country_code = data.get('countryCode')
            self.date_created = data.get('dateCreated')
            self.__token = data.get('token')
            self.userid = data.get('userId')

            # update header with the generated token
            self.__headers['Authorization'] = self.__token
478009
def _authenticate(self):
        """"""
        response = self._get("/v1/domains/{0}".format(self.domain))

        self.domain_id = response["domain"]["id"]
816598
def apply_basic_auth(params)
      headers = params.fetch(:headers, {})
      headers = basic_auth_header.merge(headers)
      params.merge(:headers => headers)
    end
1000512
def _ensure_request_id_header(self):
        ""
        if REQUEST_ID_HEADER not in self.request.headers:
            self.request.headers.add(REQUEST_ID_HEADER, uuid.uuid1().hex)
356376
def _authenticate(self):
        """"""
        data = {'username': self.username,
                'password': self.password}
        url = '{base}/client/login'.format(base=self.base_url)
        response = self._session.get(url, params=data)
        print(response.text)
        data = response.json()
        if not data.get('success'):
            raise InvalidCredentials(data.get('reason', None))
        self._populate_info(data)