code: def auth_required(*auth_methods):
      
      login_mechanisms = {
          'token': lambda: _check_token(),
          'basic': lambda: _check_http_auth(),
          'session': lambda: current_user.is_authenticated
      }
  
      def wrapper(fn):
          @wraps(fn)
          def decorated_view(*args, **kwargs):
              h = {}
              mechanisms = [(method, login_mechanisms.get(method))
                            for method in auth_methods]
              for method, mechanism in mechanisms:
                  if mechanism and mechanism():
                      return fn(*args, **kwargs)
                  elif method == 'basic':
                      r = _security.default_http_auth_realm
                      h['WWW-Authenticate'] = 'Basic realm="%s"' % r
              if _security._unauthorized_callback:
                  return _security._unauthorized_callback()
              else:
                  return _get_unauthorized_response(headers=h)
          return decorated_view
      return wrapper
docs: Decorator that protects enpoints through multiple mechanisms
      Example::
  
          @app.route('/dashboard')
          @auth_required('token', 'session')
          def dashboard():
              return 'Dashboard'
  
      :param auth_methods: Specified mechanisms.