Make a signed request to the libcal API.
18709
def _request(self, *args, **kwargs):
        """"""
        if not self.token:
            self._obtain_token()

        headers = {
            "Authorization": "Bearer {}".format(self.token)
        }

        # add authorization headers
        if "headers" in kwargs:
            kwargs["headers"].update(headers)
        else:
            kwargs["headers"] = headers

        # add api site to url
        args = list(args)
        if not args[1].startswith("http"):
            args[1] = "{}{}".format(API_URL, args[1])

        has_no_token = kwargs.get("no_token")
        if has_no_token:
            del kwargs["no_token"]
        resp = requests.request(*args, **kwargs)
        if resp.status_code == 401 and not has_no_token:
            self._obtain_token()
            kwargs["no_token"] = True
            self._request(*args, **kwargs)
        return resp
781021
def build_xoauth_string(url, consumer, token=None):
    """"""
    request = Request.from_consumer_and_token(consumer, token,
        "GET", url)

    signing_method = SignatureMethod_HMAC_SHA1()
    request.sign_request(signing_method, consumer, token)

    params = []
    for k, v in sorted(request.items()):
        if v is not None:
            params.append('%s="%s"' % (k, escape(v)))

    return "%s %s %s" % ("GET", url, ','.join(params))
131031
def exec_api_download(json_req, download_path)
      begin
        req = sign_request(json_req)
        File.open(download_path, "w") do |io|
          return HttpChannel.new(api_uri).execute_download(req) { |d| io << d; d.length }
        end
      rescue Curl::Err::CurlError => ex
        return JsonResponse.new("fail", ex.message)
      end
    end
836400
def api(name, url, token, **kwargs):
    """"""
    return Client(token).api(name, url, **kwargs)
121448
def sign(uri, headers, credentials):
    
    consumer_key, token_key, token_secret = credentials
    auth = OAuthSigner(token_key, token_secret, consumer_key, "")
    auth.sign_request(uri, method="GET", body=None, headers=headers)
770613
def sign(message: bytes, sign_key: SignKey) -> Signature:
        

        logger = logging.getLogger(__name__)
        logger.debug("Bls::sign: >>> message: %r, sign_key: %r", message, sign_key)

        c_instance = c_void_p()
        do_call('indy_crypto_bls_sign',
                message, len(message),
                sign_key.c_instance,
                byref(c_instance))

        res = Signature(c_instance)

        logger.debug("Bls::sign: <<< res: %r", res)
        return res
133718
def get_signed_request(config, context, extension):
    
    url = "https://{hostname}/".format(hostname=get_signer_hostname())

    try:
        logger.debug("Requesting signed request URL from %s", url)
        response = requests.post(
            url,
            json={
                "arn": context.invoked_function_arn,
                "requestId": context.aws_request_id,
                "timestamp": int(time.time() * 1000),
                "extension": extension,
            },
            headers={"Authorization": config["token"]},
            timeout=config["network_timeout"],
        )
        response.raise_for_status()
    except Exception as e:
        logger.debug("Error requesting signed request URL: %s", e)
        if hasattr(e, "response"):
            logger.debug(e.response.content)
    else:
        response = response.json()
        logger.debug("Signed request URL received for %s", response["url"])
        return response
357654
def check(self, request, consumer, token, signature):
        """"""
        built = self.sign(request, consumer, token)
        return built == signature
281165
def make_request(self, url, params, auth=None):
        
        req = urllib2.Request(url + urllib.urlencode(params))

        if auth:
            req.add_header('AUTHORIZATION', 'Basic ' + auth)

        return urllib2.urlopen(req)
216071
def request(self, apdu):
        """"""
        if _debug: ClientSSM._debug("request %r", apdu)

        # make sure it has a good source and destination
        apdu.pduSource = None
        apdu.pduDestination = self.pdu_address

        # send it via the device
        self.ssmSAP.request(apdu)
1249446
def create_api_interface_request(self):
        """"""

        return ApiInterfaceRequest(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
1042034
def create_request(query):
    
    yarr_url = app.config.get('YARR_URL', False)

    if not yarr_url:
        raise('No URL to Yarr! server specified in config.')

    api_token = app.config.get('YARR_API_TOKEN', False)
    headers = {'X-API-KEY': api_token} if api_token else {}
    payload = {'q': query}
    url = '%s/search' % yarr_url

    return requests.get(url, params=payload, headers=headers)
208668
def __make_request(self, requests_session, method, url, params, data, headers, certificate):
        
        verify = False
        timeout = self.timeout

        try:  # TODO : Remove this ugly try/except after fixing Java issue: http://mvjira.mv.usa.alcatel.com/browse/VSD-546
            response = requests_session.request(method=method,
                                        url=url,
                                        data=data,
                                        headers=headers,
                                        verify=verify,
                                        timeout=timeout,
                                        params=params,
                                        cert=certificate)
        except requests.exceptions.SSLError:
            try:
                response = requests_session.request(method=method,
                                            url=url,
                                            data=data,
                                            headers=headers,
                                            verify=verify,
                                            timeout=timeout,
                                            params=params,
                                            cert=certificate)
            except requests.exceptions.Timeout:
                return self._did_timeout()

        except requests.exceptions.Timeout:
            return self._did_timeout()

        return response
730704
function signAWSRequest({ credentials, request }) {
  const signer = new AWS.Signers.V4(request, 'es')
  signer.addAuthorization(credentials, new Date())
  return request
}
323199
def _make_request(self, path, method='GET', params_=None):
        """"""
        uri = self.api_root + path
        if params_:
            params_['text_format'] = self.response_format
        else:
            params_ = {'text_format': self.response_format}

        # Make the request
        response = None
        try:
            response = self._session.request(method, uri,
                                            timeout=self.timeout,
                                            params=params_)
        except Timeout as e:
            print("Timeout raised and caught:\n{e}".format(e=e))

        # Enforce rate limiting
        time.sleep(max(self._SLEEP_MIN, self.sleep_time))
        return response.json()['response'] if response else None
1316133
def send_request(self, method, url, headers=None,
                     data=None, is_retry=False):
        """"""
        if not self._token:
            self.login()

        if not headers:
            headers = {}

        headers['Authorization'] = 'Bearer ' + self._oauth_token
        headers['ABODE-API-KEY'] = self._token

        try:
            response = getattr(self._session, method)(
                url, headers=headers, json=data)

            if response and response.status_code < 400:
                return response
        except RequestException:
            _LOGGER.info("Abode connection reset...")

        if not is_retry:
            # Delete our current token and try again -- will force a login
            # attempt.
            self._token = None

            return self.send_request(method, url, headers, data, True)

        raise AbodeException((ERROR.REQUEST))
310922
def _request(self, method, *relative_path_parts, **kwargs):
        
        uri = self._create_api_uri(*relative_path_parts)
        data = kwargs.get('data', None)
        if data and isinstance(data, dict):
            kwargs['data'] = encode_params(data)
        if self.VERIFY_SSL:
            kwargs.setdefault('verify', COINBASE_CRT_PATH)
        else:
            kwargs.setdefault('verify', False)
        kwargs.update(verify=self.VERIFY_SSL)
        response = getattr(self.session, method)(uri, **kwargs)
        return self._handle_response(response)