Return an http request object

            auth: Auth data to use

            Returns:
                A HSRequest object
427743
def _get_request(self, auth=None):
        ''' 
        '''
        self.request = HSRequest(auth or self.auth, self.env)
        self.request.response_callback = self.response_callback
        return self.request
27383
def request(self, url, method, data=None, headers=None):
        
        http_headers = merge_dict(self.default_headers, headers or {})
        request_data = merge_dict({'api_key': self.apikey}, data or {})

        logger.info('HTTP %s REQUEST TO %s' % (method, url))

        start = datetime.datetime.now()

        try:
            response = requests.request(method=method, url=url, data=json.dumps(request_data),
                                        headers=http_headers)
        except exceptions.BadRequestError as e:
            return json.loads({'errors': e.content})

        duration = datetime.datetime.now() - start

        logger.info('RESPONSE %s DURATION %s.%s' % (response.encoding, duration.seconds,
                                                    duration.microseconds))

        return json.loads(response.content) if response.content else {}
157909
def _get_auth_challenge(self, exc):
        
        response = HttpResponse(content=exc.content, status=exc.get_code_num())
        response['WWW-Authenticate'] = 'Basic realm="%s"' % REALM
        return response
227452
def _request_loader(self, request: Request) -> Union[User, AnonymousUser]:
        
        header_key = self.token_authentication_header
        args_key = self.token_authentication_key
        token = request.args.get(args_key, request.headers.get(header_key, None))
        if request.is_json:
            data = request.get_json(silent=True) or {}
            token = data.get(args_key, token)

        try:
            data = self.remember_token_serializer.loads(token, max_age=self.token_max_age)
            user = self.user_manager.get(data[0])
            if user and self.security_utils_service.verify_hash(data[1], user.password):
                return user
        except:
            pass

        return self.login_manager.anonymous_user()
799591
def handle_authn_request(self, context):
        
        internal_req = self._handle_authn_request(context)
        if not isinstance(internal_req, InternalData):
            return internal_req
        return self.auth_req_callback_func(context, internal_req)
1271366
def session(self, auth=None):
        
        url = '{server}{auth_url}'.format(**self._options)

        if isinstance(self._session.auth, tuple) or auth:
            if not auth:
                auth = self._session.auth
            username, password = auth
            authentication_data = {'username': username, 'password': password}
            r = self._session.post(url, data=json.dumps(authentication_data))
        else:
            r = self._session.get(url)

        user = User(self._options, self._session, json_loads(r))
        return user
1233899
def rest_get(self, url, params=None, headers=None, auth=None, verify=True, cert=None):
        
        res = requests.get(url, params=params, headers=headers, auth=auth, verify=verify,
                           cert=cert)
        return res.text, res.status_code
647173
def request(self, method, url, **kwargs):
        

        if "data" in kwargs:
            kwargs["data"] = json.dumps(kwargs["data"])

        kwargs["headers"] = {
            'Content-Type': 'application/json',
            'Authorization': 'token %s' % self.__token__,
        }
        req = make_request(
            method,
            url,
            **kwargs
        )
        self.logger.debug(
            "Request::{}::{}".format(method, url),
            extra={
                "request": kwargs,
                "response": {"headers": req.headers, "code": req.status_code, "data": req.content}
            }
        )
        return req
1214415
def request(method, url, headers=None, data=None, session=None):
    
    base_headers = {
        'User-Agent': random_agent()
    }
    if headers is None:
        headers = {}

    base_headers.update(headers)

    if 'Content-Length' in headers:
        del base_headers['Content-Length']

    headers = base_headers
    if session is not None:
        req = session.request
    else:
        req = requests.request

    r = req(method, url, headers=headers, data=data)
    return r
643732
def get_requests(self):
        

        requests = self.derived_get_requests()

        for request in requests:
            request.url = URLHelper.remove_hash(request.url)

        return requests
725825
function getHeaders(authRequired = false) {
    if (!authRequired)
        return exports.basicHeaders;
    if ((!('X-Auth-Token' in exports.authHeaders) || !('X-User-Id' in exports.authHeaders)) ||
        exports.authHeaders['X-Auth-Token'] === '' ||
        exports.authHeaders['X-User-Id'] === '') {
        throw new Error('Auth required endpoint cannot be called before login');
    }
    return Object.assign({}, exports.basicHeaders, exports.authHeaders);
}
873498
def get_request(self, request):
        """"""
        request.headers['authenticate'] = {
            'username': self.username,
            'apiKey': self.api_key,
        }
        return request
149226
def get(self, url, data=None, params=None):
        
        return self.request("get", url, data, params)
1282278
def _get(self, *args, **kwargs):
        
        return self._request(requests.get, *args, **kwargs)
455981
def auth_request(self, url, headers, body):
        """"""

        return self.req.post(url, headers, body=body)
393569
def get_auth():
    
    import getpass
    from requests.auth import HTTPDigestAuth
    #This binds raw_input to input for Python 2
    input_func = input
    try:
        input_func = raw_input
    except NameError:
        pass
    uname = input_func("MODSCAG Username:")
    pw = getpass.getpass("MODSCAG Password:")
    auth = HTTPDigestAuth(uname, pw)
    #wget -A'h8v4*snow_fraction.tif' --user=uname --password=pw
    return auth
1244235
def authenticate(self):
        
        resp = self.session.get(self.api_url, auth=self.auth)
        resp = self._process_response(resp)
        return resp