Entry point for auth requests (ones that match the self.auth_prefix).
        Should return a WSGI-style callable (such as swob.Response).

        :param req: swob.Request object
777786
def handle_request(self, req):
        
        req.start_time = time()
        handler = None
        try:
            version, account, user, _junk = split_path(req.path_info,
                minsegs=0, maxsegs=4, rest_with_last=True)
        except ValueError:
            return HTTPNotFound(request=req)
        if version in ('v1', 'v1.0', 'auth'):
            if req.method == 'GET':
                handler = self.handle_get_token
        elif version == 'v2':
            if not self.super_admin_key:
                return HTTPNotFound(request=req)
            req.path_info_pop()
            if req.method == 'GET':
                if not account and not user:
                    handler = self.handle_get_reseller
                elif account:
                    if not user:
                        handler = self.handle_get_account
                    elif account == '.token':
                        req.path_info_pop()
                        handler = self.handle_validate_token
                    else:
                        handler = self.handle_get_user
            elif req.method == 'PUT':
                if not user:
                    handler = self.handle_put_account
                else:
                    handler = self.handle_put_user
            elif req.method == 'DELETE':
                if not user:
                    handler = self.handle_delete_account
                else:
                    handler = self.handle_delete_user
            elif req.method == 'POST':
                if account == '.prep':
                    handler = self.handle_prep
                elif user == '.services':
                    handler = self.handle_set_services
        else:
            handler = self.handle_webadmin
        if not handler:
            req.response = HTTPBadRequest(request=req)
        else:
            req.response = handler(req)
        return req.response
679825
def _request(self, typ, id=0, method='GET', params=None, data=None, url=None):
        

        headers = { "Accept": "application/json" }
        auth = None

        if self.user:
            auth = (self.user, self.password)

        if not url:
            if id:
                url = "%s/%s/%s" % (self.url, typ, id)
            else:
                url = "%s/%s" % (self.url, typ)

        return requests.request(method, url, params=params, data=data, auth=auth, headers=headers)
313445
def auth(self, request):
        
        request_token = super(ServiceTumblr, self).auth(request)
        callback_url = self.callback_url(request)

        # URL to redirect user to, to authorize your app
        auth_url_str = '{auth_url}?oauth_token={token}'
        auth_url_str += '&oauth_callback={callback_url}'
        auth_url = auth_url_str.format(auth_url=self.AUTH_URL,
                                       token=request_token['oauth_token'],
                                       callback_url=callback_url)

        return auth_url
632407
def _make_request_with_auth_fallback(self, url, headers=None, params=None):
        
        self.log.debug("Request URL and Params: %s, %s", url, params)
        try:
            resp = requests.get(
                url,
                headers=headers,
                verify=self._ssl_verify,
                params=params,
                timeout=DEFAULT_API_REQUEST_TIMEOUT,
                proxies=self.proxy_config,
            )
            resp.raise_for_status()
        except requests.exceptions.HTTPError as e:
            self.log.debug("Error contacting openstack endpoint: %s", e)
            if resp.status_code == 401:
                self.log.info('Need to reauthenticate before next check')

                # Delete the scope, we'll populate a new one on the next run for this instance
                self.delete_current_scope()
            elif resp.status_code == 409:
                raise InstancePowerOffFailure()
            elif resp.status_code == 404:
                raise e
            else:
                raise

        return resp.json()
230549
def request(self, *args, **kwargs):
        
        return self.session.request(*args, **self.get_kwargs(**kwargs))
622895
def req(self, meth, url, http_data=''):
        
        self.logger.debug("Making request: %s %s\nBody:%s" % (meth, url, http_data))
        req_method = getattr(requests, meth)
        return (req_method(url,
                           auth=(self.__username, self.__password),
                           data=http_data,
                           headers=({'user-agent': self.user_agent(), 'Accept': 'application/json'})))
558185
def auth(self, request):
        
        request_token = super(ServiceTrello, self).auth(request)
        callback_url = self.callback_url(request)

        # URL to redirect user to, to authorize your app
        auth_url_str = '{auth_url}?oauth_token={token}'
        auth_url_str += '&scope={scope}&name={name}'
        auth_url_str += '&expiration={expiry}&oauth_callback={callback_url}'
        auth_url = auth_url_str.format(auth_url=self.AUTH_URL,
                                       token=request_token['oauth_token'],
                                       scope=self.scope,
                                       name=self.app_name,
                                       expiry=self.expiry,
                                       callback_url=callback_url)

        return auth_url
826255
def request(self, *args, **kwargs):
        
        return RequestsHandler(*args, api_token=self.api_token,
                               verify=self.mist_client.verify,
                               job_id=self.mist_client.job_id, **kwargs)
395226
def request(self, method, url, **kwargs):  # pylint: disable=arguments-differ
        
        self._check_auth()
        return super(OAuthAPIClient, self).request(method, url, **kwargs)
418219
def authenticate(self, reauth=False):
        
        auth_url = BASE_URL + "/rest/user"
        payload = {'email': self.email, 'password': self.password}
        arequest = requests.get(auth_url, params=payload)
        status = arequest.status_code
        if status != 200:
            if reauth:
                _LOGGER.error("Reauthentication request failed. " + status)
            else:
                _LOGGER.error("Authentication request failed, please check credintials. " + status)
        self.token = arequest.json().get('usertoken')
        if reauth:
            _LOGGER.info("Reauthentication was successful, token updated.")
        else:
            _LOGGER.info("Authentication was successful, token set.")
890519
function authRequired (req, res, next) {
  if (!req.user) {
    req.session.oauth2return = req.originalUrl;
    return res.redirect('/login');
  }
  if (req.session.allowedDomain && req.session.allowedDomain !== req.user.domain) {
    return res.redirect('/login');
  }
  next();
}
755232
def request(http_method, uri, options={})
      response = self.class.__send__(http_method, uri, options.merge(basic_auth))
      # Add some logger.debug here ...
      response
    end
293906
def request(self, method, path, **kwargs):
        
        if path:
            url = '%s/%s' % (self.url.rstrip('/'), path.lstrip('/'))
        else:
            url = self.url

        request_params = self._get_request_params(method=method,
                                                  url=url, **kwargs)
        request_params = self.pre_send(request_params)

        sanitized_params = self._sanitize_request_params(request_params)
        start_time = time.time()
        response = super(HTTPServiceClient, self).request(**sanitized_params)

        # Log request and params (without passwords)
        log.debug(
            '%s HTTP [%s] call to "%s" %.2fms',
            response.status_code, method, response.url,
            (time.time() - start_time) * 1000)
        auth = sanitized_params.pop('auth', None)
        log.debug('HTTP request params: %s', sanitized_params)
        if auth:
            log.debug('Authentication via HTTP auth as "%s"', auth[0])

        response.is_ok = response.status_code < 300
        if not self.is_acceptable(response, request_params):
            raise HTTPServiceError(response)
        response = self.post_send(response, **request_params)
        return response
640731
def request(self, *args, **kwargs):
        
        r = self.session.request(*args, **kwargs)
        if r.status_code != requests.codes.ok:
            error = ET.fromstring(r.content)
            message = error.findtext('message')
            code = error.attrib['key']
            raise CleanwebError('%s (%s)' % (message, code))
        return r
1170656
def raw_request(self, method, resource, access_token=None, **kwargs):
        
        headers = self._pop_headers(kwargs)
        headers['Authorization'] = self._get_authorization_header(access_token)
        url = self._get_resource_url(resource)
        return self.session.request(method, url, allow_redirects=True, headers=headers, **kwargs)
1024418
def _request(self, method, url, **kwargs):
        '''  '''
        self._ask_for_password()
        return request(method, url, user=self._user, password=self._password,
                       **kwargs)
407968
def request(self, method, url, **kwargs):
        '''
        '''
        # TODO should we raise an exception if auth or cookies are explicitly
        # mentioned in kwargs?
        kwargs['auth'] = self.auth()
        kwargs['cookies'] = self.cookies
        return requests.request(method=method, url=url, **kwargs)