code: def _auth_required():
      
  
      login_mechanisms = (
          ('token', lambda: _check_token()),
          ('session', lambda: current_user.is_authenticated),
      )
  
      def wrapper(fn):
          @wraps(fn)
          def decorated_view(*args, **kwargs):
              for method, mechanism in login_mechanisms:
                  if mechanism and mechanism():
                      return fn(*args, **kwargs)
              return security._unauthorized_callback()
          return decorated_view
      return wrapper
docs: Decorator that protects endpoints through token and session auth mechanisms