def _get_event(receiver_id, event_id):
        """Find event and check access rights."""
        event = Event.query.filter_by(
            receiver_id=receiver_id, id=event_id
        ).first_or_404()

        try:
            user_id = request.oauth.access_token.user_id
        except AttributeError:
            user_id = current_user.get_id()

        if event.user_id != int(user_id):
            abort(401)

        return event
Find event and check access rights.