text: from itsdangerous import URLSafeTimedSerializer
  
  
  def generate_confirmation_token(app, email):
      serializer = URLSafeTimedSerializer(app.config['SECRET_KEY'])
      return serializer.dumps(email, salt=app.config['SECURITY_PASSWORD_SALT'])
  
  
  def confirm_token(app, token, expiration=345600):  # Default is 4 days expiration
      serializer = URLSafeTimedSerializer(app.config['SECRET_KEY'])
      try:
          email = serializer.loads(
              token,
              salt=app.config['SECURITY_PASSWORD_SALT'],
              max_age=expiration
          )
      except:
          return False
  
      return email
  