Creates the http headers object for this request, populated from data in
the session.
@throws AuthenticationException If OAuth authorization fails.
494753
private HttpHeaders createHeaders(String reportUrl, String version)
      throws AuthenticationException {
    HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.setAuthorization(
        authorizationHeaderProvider.getAuthorizationHeader(session, reportUrl));
    httpHeaders.setUserAgent(userAgentCombiner.getUserAgent(session.getUserAgent()));
    httpHeaders.set("developerToken", session.getDeveloperToken());
    httpHeaders.set("clientCustomerId", session.getClientCustomerId());
    ReportingConfiguration reportingConfiguration = session.getReportingConfiguration();
    if (reportingConfiguration != null) {
      reportingConfiguration.validate(version);
      if (reportingConfiguration.isSkipReportHeader() != null) {
        httpHeaders.set("skipReportHeader",
            Boolean.toString(reportingConfiguration.isSkipReportHeader()));
      }
      if (reportingConfiguration.isSkipColumnHeader() != null) {
        httpHeaders.set("skipColumnHeader",
            Boolean.toString(reportingConfiguration.isSkipColumnHeader()));
      }
      if (reportingConfiguration.isSkipReportSummary() != null) {
        httpHeaders.set("skipReportSummary",
            Boolean.toString(reportingConfiguration.isSkipReportSummary()));
      }
      if (reportingConfiguration.isIncludeZeroImpressions() != null) {
        httpHeaders.set(
            "includeZeroImpressions",
            Boolean.toString(reportingConfiguration.isIncludeZeroImpressions()));
      }
      if (reportingConfiguration.isUseRawEnumValues() != null) {
        httpHeaders.set(
            "useRawEnumValues",
            Boolean.toString(reportingConfiguration.isUseRawEnumValues()));
      }
    }
    return httpHeaders;
  }
1004112
public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {/*{{{*/
    $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on") ? 'http' : 'https';
    @$http_url or $http_url = $scheme . '://' . $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];
    @$http_method or $http_method = $_SERVER['REQUEST_METHOD'];

    $request_headers = OAuthRequest::get_headers();

    // let the library user override things however they'd like, if they know
    // which parameters to use then go for it, for example XMLRPC might want to
    // do this
    if ($parameters) {
      $req = new OAuthRequest($http_method, $http_url, $parameters);
    } else {
      // collect request parameters from query string (GET) and post-data (POST) if appropriate (note: POST vars have priority)
      $req_parameters = $_GET;
      if ($http_method == "POST" && @strstr($request_headers["Content-Type"], "application/x-www-form-urlencoded") ) {
        $req_parameters = array_merge($req_parameters, $_POST);
      }

      // next check for the auth header, we need to do some extra stuff
      // if that is the case, namely suck in the parameters from GET or POST
      // so that we can include them in the signature
      if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
        $header_parameters = OAuthRequest::split_header($request_headers['Authorization']);
        $parameters = array_merge($req_parameters, $header_parameters);
        $req = new OAuthRequest($http_method, $http_url, $parameters);
      } else $req = new OAuthRequest($http_method, $http_url, $req_parameters);
    }

    return $req;
  }
990666
private void setPreemptiveAuth(FedoraHttpClient httpClient) {
        this.localContext = new BasicHttpContext();
        BasicScheme basicAuth = new BasicScheme();
        localContext.setAttribute("preemptive-auth", basicAuth);
        httpClient.addRequestInterceptor(new PreemptiveAuthInterceptor(), 0);
    }
849980
def make_auth_headers():
    """"""
    if not os.path.exists(".appveyor.token"):
        raise RuntimeError(
            "Please create a file named `.appveyor.token` in the current directory. "
            "You can get the token from https://ci.appveyor.com/api-token"
        )
    with open(".appveyor.token") as f:
        token = f.read().strip()

    headers = {
        'Authorization': 'Bearer {}'.format(token),
    }
    return headers
906120
public void setAuthentication(HttpURLConnection http) {
		
		if(user == null || pass == null 
				|| user.length() <= 0 || pass.length() <= 0) {
			return;
		}

		String base64login = Base64.encode(user + ":" + pass);

		http.addRequestProperty("Authorization", "Basic " + base64login);
		
	}
1284308
@Override
    public Subject createHashtableInSubject(String username, @Sensitive String password) throws AuthenticationException {
        UsernamePasswordCredential credential = new UsernamePasswordCredential(username, password);
        return createHashtableInSubject(credential);
    }
986529
private String getAuthHeader(HttpServletRequest request, String authType)
      throws HttpAuthenticationException {
    String authHeader = request.getHeader(HttpAuthUtils.AUTHORIZATION);
    // Each http request must have an Authorization header
    if (authHeader == null || authHeader.isEmpty()) {
      throw new HttpAuthenticationException("Authorization header received " +
          "from the client is empty.");
    }

    String authHeaderBase64String;
    int beginIndex;
    if (isKerberosAuthMode(authType)) {
      beginIndex = (HttpAuthUtils.NEGOTIATE + " ").length();
    }
    else {
      beginIndex = (HttpAuthUtils.BASIC + " ").length();
    }
    authHeaderBase64String = authHeader.substring(beginIndex);
    // Authorization header must have a payload
    if (authHeaderBase64String == null || authHeaderBase64String.isEmpty()) {
      throw new HttpAuthenticationException("Authorization header received " +
          "from the client does not contain any data.");
    }
    return authHeaderBase64String;
  }
586377
public Response andHeaders(Map<HttpString, String> headers) {
        Objects.requireNonNull(headers, Required.HEADERS.toString());
        this.headers.putAll(headers);

        return this;
    }
1039772
public T create(Map<String, Object> hash, MnoHttpClient httpClient) throws AuthenticationException, ApiException, InvalidRequestException {
		String jsonBody = httpClient.post(getCollectionUrl(), GSON.toJson(MnoMapHelper.toUnderscoreHash(hash)));

		Type parsingType = new MnoAccountResponseParameterizedType(entitityClass);
		MnoAccountResponse<T> resp = GSON.fromJson(jsonBody, parsingType);
		resp.validate();

		return resp.getData();
	}
270951
public function createAuthHeader()
    {
        if ($this->timestamp === null) {
            $this->setTimestamp();
        }

        if (!$this->timestamp->isValid()) {
            throw new InvalidSignDataException('Timestamp is invalid. Too old?');
        }

        if ($this->nonce === null) {
            $this->nonce = new Nonce();
        }

        $auth_header =
            'EG1-HMAC-SHA256 ' .
            'client_token=' . $this->auth['client_token'] . ';' .
            'access_token=' . $this->auth['access_token'] . ';' .
            'timestamp=' . $this->timestamp . ';' .
            'nonce=' . $this->nonce . ';';

        return $auth_header . 'signature=' . $this->signRequest($auth_header);
    }
855758
protected HttpRequest addAuthHeader(HttpRequest request) {
        if (authToken != null) {
            request.header("authorization", "Bearer " + authToken);
        }

        return request;
    }
523747
protected function prepareHeaders()
    {
        if (!isset($this->headers['Content-Length'])) {

            $content_length = strlen($this->data);

            if ($content_length > 0 || $this->method === 'POST' || $this->method === 'PUT') {
                $this->headers['Content-Length'] = $content_length;
            }
        }

        if (isset($this->uri['user']) && !isset($this->headers['Authorization'])) {
            $pass = isset($this->uri['pass']) ? ':' . $this->uri['pass'] : ':';
            $this->headers['Authorization'] = 'Basic ' . base64_encode($this->uri['user'] . $pass);
        }
    }
658589
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
        header($headerName.':'.$this->_getAuthenticateChallengeHeader());
        header("HTTP/1.0 {$statusCode} Unauthorized");
    }
571359
private function GetHttpHeaderStrong()
    {
        $token = $this->_root->OAuthTokenManager->GetToken($this->GetAutenticationKey());

        if (is_null($token) || !isset($token->access_token) || !isset($token->token_type)) {
            throw new Exception('OAuth token is not created (or is invalid) for strong authentication');
        }

        return 'Authorization: ' . $token->token_type . ' ' . $token->access_token;
    }
1251614
public HttpHeaders generatePreflightResponseHeaders() {
        final HttpHeaders headers = new DefaultHttpHeaders();
        preflightResponseHeaders.forEach((key, value) -> {
            final Object val = getValue(value);
            if (val instanceof Iterable) {
                headers.addObject(key, (Iterable<?>) val);
            } else {
                headers.addObject(key, val);
            }
        });
        return headers.asImmutable();
    }
504003
private Map<String, String> getHttpHeaderStrong() throws Exception {
        
        final OAuthToken token = root.getOAuthTokenManager().getToken();
        
        if (token == null || token.getAccessToken().length() == 0 || token.getTokenType().length() == 0)
            throw new Exception ("OAuth token is not created (or is invalid) for strong authentication");
                
        return new HashMap<String, String>(){{
            put("Authorization", token.getTokenType() + " " + token.getAccessToken());
        }};
    }
940336
private function createHeader($parameters)
	{
		$header = 'OAuth ';

		foreach ($parameters as $key => $value)
		{
			if (!strcmp($header, 'OAuth '))
			{
				$header .= $key . '="' . $this->safeEncode($value) . '"';
			}
			else
			{
				$header .= ', ' . $key . '="' . $value . '"';
			}
		}

		return $header;
	}