title: How to implement login required decorator in Flask
body: <p>I have 2 Flask apps (different projects) that work together . One implements some API which uses tokens for auth. The second one consumes the API and makes a web interface for it. Now I have a login function that sends the username and password to the API, and if correct, gets the auth token in return. Once I have the token, I save it to the session of the user and the user should now be considered as logged in/ autheticated. How can I implement the login_required decorator for such a case.</p>
  
  <p>Here is my login function - </p>
  
  <pre><code> def login(self):
          response = make_request(BASE_URL + 'login/', clean_data(self.data))
          if response.status_code == 200:
              session['auth_token'] = response.json().get('auth_token')
              return True
          return False
  </code></pre>
  
  <p>How can I make the login_required decorator?</p>
  
  <p>Also I am using Redis to store sessions if that matters.</p>