Skip to content

Exceptions

The telegram_webapp_auth.errors module defines the public exception hierarchy raised by validation.

Catch InvalidInitDataError and ExpiredInitDataError at your HTTP boundary and translate them into your framework's authorization response.

BaseTWAError

Bases: Exception

Base class for all TWA-related exceptions.

Source code in telegram_webapp_auth/errors.py
1
2
3
4
class BaseTWAError(Exception):
    """Base class for all TWA-related exceptions."""

    pass

ExpiredInitDataError

Bases: BaseTWAError

Raised when the init data has expired.

Source code in telegram_webapp_auth/errors.py
class ExpiredInitDataError(BaseTWAError):
    """Raised when the init data has expired."""

    pass

InvalidInitDataError

Bases: BaseTWAError

Raised when the init data is invalid.

Source code in telegram_webapp_auth/errors.py
class InvalidInitDataError(BaseTWAError):
    """Raised when the init data is invalid."""

    pass