title: Flask: How to store credentials in session and retrieve them?
body: <p>I am working on a project where each of my <code>REST</code> endpoints needs to be authenticated. An example is</p>
  
  <pre><code>@login_required
  def get_transactions(self):
    pass
  </code></pre>
  
  <p>I have a <code>User</code> model which looks like </p>
  
  <pre><code>class User(UserMixin, db.Model):
      __tablename__ = 'users'
      # noinspection PyShadowingBuiltins
      uuid = Column('uuid', GUID(), default=uuid.uuid4, primary_key=True,
                    unique=True)
      email = Column('email', String, nullable=False, unique=True)
      _password = Column('password', String, nullable=False)
      created_on = Column('created_on', sa.types.DateTime(timezone=True),
                          default=datetime.utcnow(), nullable=False)
      last_login = Column('last_login', sa.types.DateTime(timezone=True),
                          onupdate=datetime.utcnow())
  
      def __init__(self, email, password):
          self.email = email
          self._password = hash_password(password) # hash_password does md5 of password
  </code></pre>
  
  <ul>
  <li>Once the user is logged in I want to store a security token on client session and would like each further request to have that token</li>
  <li>I looked for examples, but did not understand how I can save such a security token in client session PLUS</li>
  <li>How can I make sure that further requests send me that token from client session.</li>
  </ul>
  
  <p>I do not know how that works, please help</p>