platypush/user/__init__.py
def generate_jwt_token(self, username: str, password: str, expires_at: Optional[datetime.datetime] = None) -> str:
        """
        Create a user JWT token for API usage.

        :param username: User name.
        :param password: Password.
        :param expires_at: Expiration datetime of the token.
        :return: The generated JWT token as a string.
        :raises: :class:`platypush.exceptions.user.InvalidCredentialsException` in case of invalid credentials.
        """
        user = self.authenticate_user(username, password)
        if not user:
            raise InvalidCredentialsException()

        pub_key, priv_key = get_or_generate_jwt_rsa_key_pair()
        payload = {
            'username': username,
            'created_at': datetime.datetime.now().timestamp(),
            'expires_at': expires_at.timestamp() if expires_at else None,
        }

        token = jwt_encode(payload, priv_key, algorithm='RS256')
        if isinstance(token, bytes):
            token = token.decode()
        return token

        Create a user JWT token for API usage.

        :param username: User name.
        :param password: Password.
        :param expires_at: Expiration datetime of the token.
        :return: The generated JWT token as a string.
        :raises: :class:`platypush.exceptions.user.InvalidCredentialsException` in case of invalid credentials.
        
Create a user JWT token for API usage.
Create a user JWT token for API usage .
def generate_jwt_token(self, username: str, password: str, expires_at: Optional[datetime.datetime] = None) -> str:
        user = self.authenticate_user(username, password)
        if not user:
            raise InvalidCredentialsException()
        pub_key, priv_key = get_or_generate_jwt_rsa_key_pair()
        payload = {
            'username': username,
            'created_at': datetime.datetime.now().timestamp(),
            'expires_at': expires_at.timestamp() if expires_at else None,
        }
        token = jwt_encode(payload, priv_key, algorithm='RS256')
        if isinstance(token, bytes):
            token = token.decode()
        return token
def generate_jwt_token ( self , username : str , password : str , expires_at : Optional [ datetime . datetime ] = None ) -> str : user = self . authenticate_user ( username , password ) if not user : raise InvalidCredentialsException ( ) pub_key , priv_key = get_or_generate_jwt_rsa_key_pair ( ) payload = { 'username' : username , 'created_at' : datetime . datetime . now ( ) . timestamp ( ) , 'expires_at' : expires_at . timestamp ( ) if expires_at else None , } token = jwt_encode ( payload , priv_key , algorithm = 'RS256' ) if isinstance ( token , bytes ) : token = token . decode ( ) return token
Create a user JWT token for API usage.
Create a user JWT token for API usage .
"""
        Create a user JWT token for API usage.

        :param username: User name.
        :param password: Password.
        :param expires_at: Expiration datetime of the token.
        :return: The generated JWT token as a string.
        :raises: :class:`platypush.exceptions.user.InvalidCredentialsException` in case of invalid credentials.
        """
The generated JWT token as a string.
The generated JWT token as a string .
:class:`platypush.exceptions.user.InvalidCredentialsException` in case of invalid credentials.
: class : ` platypush . exceptions . user . InvalidCredentialsException ` in case of invalid credentials .
self
username
str
None
password
str
None
expires_at
Optional[datetime.datetime]
Expiration datetime of the token.
Expiration datetime of the token .