UnauthorizedError
342818
function  (options, status) {
  this.name = ''
  this.error = options.error
  this.error_description = options.error_description
  this.message = options.error_description
  // this.realm             = options.realm
  // this.scope             = options.scope
  this.statusCode = options.statusCode || 401
}
78112
def http_error_401(self, url, fp, errcode, errmsg, headers, data=None,
            retry=False):
        """"""
        if 'www-authenticate' not in headers:
            URLopener.http_error_default(self, url, fp,
                                         errcode, errmsg, headers)
        stuff = headers['www-authenticate']
        match = re.match('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff)
        if not match:
            URLopener.http_error_default(self, url, fp,
                                         errcode, errmsg, headers)
        scheme, realm = match.groups()
        if scheme.lower() != 'basic':
            URLopener.http_error_default(self, url, fp,
                                         errcode, errmsg, headers)
        if not retry:
            URLopener.http_error_default(self, url, fp, errcode, errmsg,
                    headers)
        name = 'retry_' + self.type + '_basic_auth'
        if data is None:
            return getattr(self,name)(url, realm)
        else:
            return getattr(self,name)(url, realm, data)
276545
def permission_denied(self, request, message=None):
        
        if not request.successful_authenticator:
            raise exceptions.NotAuthenticated()
        raise exceptions.PermissionDenied(detail=message)
1321788
def authorized?(options = {})
      raise "Configuration values not found. Please run rails g restful_api_authentication:install to generate a config file." if @@header_timestamp.nil? || @@header_signature.nil? || @@header_api_key.nil? || @@time_window.nil? || @@disabled_message.nil?
      return_val = false
      if headers_have_values?
        if in_time_window?
          if test_hash.downcase == @http_headers[@@header_signature].downcase
            if is_disabled?
              @errors << @@disabled_message
              return false
            end
            if options[:require_master] == true
              if is_master?
                return_val = true
              else
                @errors << "client does not have the required permissions"
              end
            else
              return_val = true
            end
          else
            @errors << "signature is invalid"
          end
        else
          @errors << "request is outside the required time window of #{@@time_window.to_s} minutes"
        end
      else
        @errors << "one or more required headers is missing"
      end
      if return_val == false && @errors.count == 0
        @errors << "authentication failed"
      end
      return_val
    end
910688
def requires_auth(func):
    """"""
    @wraps(func)
    def auth_wrapper(self, *args, **kwargs):
        auth = False
        if hasattr(self, '_session'):
            auth = (self._session.auth or
                    self._session.headers.get('Authorization'))

        if auth:
            return func(self, *args, **kwargs)
        else:
            from .models import GitHubError
            # Mock a 401 response
            r = generate_fake_error_response(
                '{"message": "Requires authentication"}'
            )
            raise GitHubError(r)
    return auth_wrapper
205264
def gitlab_user_exists?(gitlab_url, private_token)
      with_gitlab(gitlab_url, private_token) do |g|
        g.user
      end

      true
    rescue Gitlab::Error::Unauthorized
      false
    end
14593
function Unauthorized(message, cause) {
    Unauthorized.super_.call(this, message, StatusCode.UNAUTHORIZED, cause);
}
248719
public static Unauthorized of(int errorCode, String message) {
        touchPayload().errorCode(errorCode).message(message);
        return _INSTANCE;
    }
375998
def handle_backend_error(self, exception):
        
        auth_req = self._get_authn_request_from_state(exception.state)
        # If the client sent us a state parameter, we should reflect it back according to the spec
        if 'state' in auth_req:
            error_resp = AuthorizationErrorResponse(error="access_denied",
                                                    error_description=exception.message,
                                                    state=auth_req['state'])
        else:
            error_resp = AuthorizationErrorResponse(error="access_denied",
                                                    error_description=exception.message)
        satosa_logging(logger, logging.DEBUG, exception.message, exception.state)
        return SeeOther(error_resp.request(auth_req["redirect_uri"], should_fragment_encode(auth_req)))
368622
function prepareConfig(config) {
  if (!('authorizationError' in config)) {
    config.authorizationError = {status: 401, message: 'Unauthorized'};
  }
  if (!('unauthorizedOnly' in config)) {
    config.unauthorizedOnly = false;
  }
}
42347
protected function _handleUnauthenticatedAccess()
    {
        header("HTTP/1.0 401 Unauthorized");
        $renderer = new TwigRenderer();
        $output = $renderer->render('unauth.tmpl', array());
        $result = array("code"=>"401","message" => $output);
        echo parent::encodeData($result);
        exit;

    }
1240791
def ip_verification_required(func):
    

    def wrapper(request, *args, **kwargs):

        slug = kwargs.get('slug', "")
        if not slug:
            return kickoutt_404("Not found.", content_type="application/json")

        try:
            wip = WriteAPIIP.objects.get(slug=slug)
            ip = get_client_ip(request)
            if ip not in wip.allowable_ips() and "0.0.0.0" not in wip.allowable_ips():
                msg = "The IP %s is not authorized to make the API call." % (
                    ip)
                return kickout_401(msg)

        except WriteAPIIP.DoesNotExist:
            return HttpResponse(unauthorized_json_response(),
                                content_type="application/json")

        return func(request, *args, **kwargs)

    return update_wrapper(wrapper, func)
1169982
function defaultErrorHandler(err, req, res) {
  if (err.name === 'UnauthorizedError') { // authentication is expected to be a common use-case
    res.status(401).end();
  } else {
    if (!err.status || err.status >= 500) {
      console.error(err.stack || err.toString());
    }
    res.status(err.status || 500).json({message: err.message})
  }
}
1062724
protected function unauthorizedException(Request $request, Response $response, $message = 'Unauthorized.')
    {
        return new UnauthorizedException($request, $response, $message);
    }
360657
def error_class_for(status)
      case status
      when 400 then Esi::ApiBadRequestError
      when 401 then Esi::UnauthorizedError
      when 403 then Esi::ApiForbiddenError
      when 404 then Esi::ApiNotFoundError
      when 502 then Esi::TemporaryServerError
      when 503 then Esi::RateLimitError
      else Esi::ApiUnknownError
      end
    end
1198725
def unauthorized_callback(self):
        
        return redirect(self.login_url(params=dict(next=request.url)))
1029455
def authenticate!(options = {}, connection = self.connection)
      creds = options.to_json
      connection.post('/auth', {}, :body => creds)
      @creds = creds
      true
    rescue Docker::Error::ServerError, Docker::Error::UnauthorizedError
      raise Docker::Error::AuthenticationError
    end