code: def default_token_implementation(self, user_id):
          
          user = self.get(user_id)
          if not user:
              msg = 'No user with such id [{}]'
              raise x.JwtNoUser(msg.format(user_id))
  
          # return token if exists and valid
          if user._token:
              try:
                  self.decode_token(user._token)
                  return user._token
              except jwt.exceptions.ExpiredSignatureError:
                  pass
  
          from_now = datetime.timedelta(seconds=self.jwt_lifetime)
          expires = datetime.datetime.utcnow() + from_now
          issued = datetime.datetime.utcnow()
          not_before = datetime.datetime.utcnow()
          data = dict(
              exp=expires,
              nbf=not_before,
              iat=issued,
              user_id=user_id
          )
          token = jwt.encode(data, self.jwt_secret, algorithm=self.jwt_algo)
          string_token = token.decode('utf-8')
          user._token = string_token
          self.save(user)
          return string_token
docs: Default JWT token implementation
          This is used by default for generating user tokens if custom
          implementation was not configured. The token will contain user_id and
          expiration date. If you need more information added to the token,
          register your custom implementation.
  
          It will load a user to see if token is already on file. If it is, the
          existing token will be checked for expiration and returned if valid.
          Otherwise a new token will be generated and persisted. This can be used
          to perform token revocation.
  
          :param user_id: int, user id
          :return: string