Handles response after the redirect to GitHub. This response
        determines if the user has allowed the this application access. If we
        were then we send a POST request for the access_key used to
        authenticate requests to GitHub.
12784
def _handle_response(self):
        
        _logger.debug("Handling response from GitHub")
        params = {
            'code': request.args.get('code'),
            'client_id': self.client_id,
            'client_secret': self.client_secret
        }
        url = self.auth_url + 'access_token'
        _logger.debug("POSTing to %s", url)
        _logger.debug(params)
        response = self.session.post(url, data=params)
        data = parse_qs(response.content)
        _logger.debug("response.content = %s", data)
        for k, v in data.items():
            if len(v) == 1:
                data[k] = v[0]
        token = data.get(b'access_token', None)
        if token is not None:
            token = token.decode('ascii')
        return token
1050017
function authenticate(req, cb) {
    request.post(
      'https://github.com/login/oauth/access_token',
      { form:
        { client_id: process.env.GHID,      // don't store credentials in opts
          client_secret: process.env.GHCS,  // get them straight from process.env
          code: req.query.code } },
      function(err, resp, body) {
        if (err) return cb(err);
        var result = qs.parse(body);
        getUser(req, result, function() {
          cb(null, result);
        });
      }
    );
  }
1063849
protected void handle(Authentication authentication) throws IOException, ServletException {
        HttpServletRequest request = http.getCurrentRequest();
        HttpServletResponse response = http.getCurrentResponse();
        String targetUrl = determineTargetUrl(request, response);

        if (response.isCommitted()) {
            logger.debug("Response has already been committed. Unable to redirect to " + targetUrl);
            return;
        } else {
            logger.debug("Redirecting to " + targetUrl);
        }

        redirectStrategy.sendRedirect(targetUrl);
    }
43601
def response_hook(self, r, **kwargs):
        """"""
        if r.status_code == 401:
            # Handle server auth.
            www_authenticate = r.headers.get('www-authenticate', '').lower()
            auth_type = _auth_type_from_header(www_authenticate)

            if auth_type is not None:
                return self.retry_using_http_NTLM_auth(
                    'www-authenticate',
                    'Authorization',
                    r,
                    auth_type,
                    kwargs
                )
        elif r.status_code == 407:
            # If we didn't have server auth, do proxy auth.
            proxy_authenticate = r.headers.get(
                'proxy-authenticate', ''
            ).lower()
            auth_type = _auth_type_from_header(proxy_authenticate)
            if auth_type is not None:
                return self.retry_using_http_NTLM_auth(
                    'proxy-authenticate',
                    'Proxy-authorization',
                    r,
                    auth_type,
                    kwargs
                )

        return r
1262843
def request_access_token(self, access_code):
        ""
        token_response = request_session.post(
            "https://github.com/login/oauth/access_token",
            data={
                "client_id": self.oauth_client_id,
                "client_secret": self.oauth_client_secret,
                "code": access_code
            },
            headers={"Accept": "application/json"},
        )
        return helper_request_access_token(token_response.json())
178836
def handle_response(response)
      case response.code.to_i
        when 301,302
          raise "Redirect"
        when 200...400
          response
        when 400
          raise "Bad Request"
        when 401
          raise "Unauthorized Access"
        when 403
          raise "Forbidden Access"
        when 404
          raise "Rescoure not found"
        when 405
          raise "Method not allowed"
        when 409
          raise RequestError.new("Rescource conflict")
        when 422
          raise RequestError.new("Resource invalid")
        when 401...500
          raise "Client error"
        when 500...600
          raise RequestError.new("Server error")
        else
          raise "Unknown response: #{response.code.to_i}"
      end
    end
1255206
def handle_new_user(self, provider, access, info):
        ""
        user = self.get_or_create_user(provider, access, info)
        access.user = user
        AccountAccess.objects.filter(pk=access.pk).update(user=user)
        user = authenticate(provider=access.provider, identifier=access.identifier)
        login(self.request, user)
        return redirect(self.get_login_redirect(provider, user, access, True))
115957
function getUser(req, result, cb) {
    if (!result || !result.access_token) return process.nextTick(cb);
    request.get(
      'https://api.github.com/user/emails?access_token=' + result.access_token,
      { headers:{ 'Accept':'application/vnd.github.v3+json' } },
      function(err, resp, body) {
        if (err) { debug(err); return cb(err); }
        var list = JSON.parse(body); debug(list);
        var email = u.find(list, function(entry) { return entry.primary; });
        if (email) {
          email = email.email;
          if (req.session && !req.session.user) { req.session.user = email; }
          result.user = email;
        }
        cb();
    });
  }
83144
def post_parse_response(self, response, **kwargs):
        

        if "scope" not in response:
            try:
                _key = kwargs['state']
            except KeyError:
                pass
            else:
                if _key:
                    item = self.get_item(oauth2.AuthorizationRequest,
                                         'auth_request', _key)
                    try:
                        response["scope"] = item["scope"]
                    except KeyError:
                        pass
        return response
617158
def post(self, request):
        
        if constants.ENFORCE_SECURE and not request.is_secure():
            return self.error_response({
                'error': 'invalid_request',
                'error_description': _("A secure connection is required.")})

        if not 'grant_type' in request.POST:
            return self.error_response({
                'error': 'invalid_request',
                'error_description': _("No 'grant_type' included in the "
                    "request.")})

        grant_type = request.POST['grant_type']

        if grant_type not in self.grant_types:
            return self.error_response({'error': 'unsupported_grant_type'})

        client = self.authenticate(request)

        if client is None:
            return self.error_response({'error': 'invalid_client'})

        handler = self.get_handler(grant_type)

        try:
            return handler(request, request.POST, client)
        except OAuthError, e:
            return self.error_response(e.args[0])
333056
def post(path, body)
      LOG.debug("post #{body} to \"#{path}\"")
      response = @access_token.post(path, body)
      parse_response(response)
    end
678232
def after_request(self, response):
        
        if response is not None and request is not None:
            # When used as response processor, only run if we are requesting
            # anything but a static resource.
            if request.endpoint in [None, "static"]:
                return response
        self.compile()
        return response
627762
def post(self, request, *args, **kwargs):
        
        return self.unlock(request, *args, **kwargs)
64818
def is_redirect(self):
        ''''''
        if self._response:
            status_code = self._response.status_code
            return status_code in self._codes \
                or status_code in self._repeat_codes
116070
private void handleResponse(HandshakerResp resp) throws GeneralSecurityException {
    status = resp.getStatus();
    if (resp.hasResult()) {
      result = resp.getResult();
      close();
    }
    if (status.getCode() != Status.Code.OK.value()) {
      String error = "Handshaker service error: " + status.getDetails();
      logger.log(Level.INFO, error);
      close();
      throw new GeneralSecurityException(error);
    }
  }
824632
def handle_3ds_response(payment, response)
      if response.success?
        payment.update_columns(state: 'pending', response_code: response.psp_reference)
        payment.update_adyen_card_data
      else
        raise Authorize3DSecureError
      end
    end
660862
def POST_query(self, req_hook, req_args):
        '''  '''
        # HTTP POST queries require keyManagerTokens and sessionTokens
        headers = {'Content-Type': 'application/json',
                   'sessionToken': self.__session__,
                   'keyManagerToken': self.__keymngr__}

        # HTTP POST query to keymanager authenticate API
        try:
            if req_args is None:
                response = requests.post(self.__url__ + req_hook,
                                         headers=headers,
                                         verify=True)
            else:
                response = requests.post(self.__url__ + req_hook,
                                         headers=headers,
                                         data=req_args,
                                         verify=True)
        except requests.exceptions.RequestException as err:
            self.logger.error(err)
            return '500', 'Internal Error in RESTful.POST_query()'
        # return the token
        return response.status_code, response.text