Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# PassportData

class telegram.PassportData(data, credentials, *, api_kwargs=None)

  Bases: `telegram.TelegramObject`

  Contains information about Telegram Passport data shared with the bot by the user.

  Note

  To be able to decrypt this object, you must pass your `private_key` to either `telegram.ext.Updater` or `telegram.Bot`. Decrypted data is then found in `decrypted_data` and the payload can be found in `decrypted_credentials`’s attribute `telegram.Credentials.nonce`.

  Available In

  `telegram.Message.passport_data`

  Parameters:

    - data (Sequence[`telegram.EncryptedPassportElement`]) –

      Array with encrypted information about documents and other Telegram Passport elements that was shared with the bot.

      Changed in version 20.0: Accepts any `collections.abc.Sequence` as input instead of just a list. The input is converted to a tuple.

    - credentials (`telegram.EncryptedCredentials`)) – Encrypted credentials.

  data

    Array with encrypted information about documents and other Telegram Passport elements that was shared with the bot.

    Changed in version 20.0: This attribute is now an immutable tuple.

    Type:

      tuple[`telegram.EncryptedPassportElement`]

  credentials

    Encrypted credentials.

    Type:

      `telegram.EncryptedCredentials`

  classmethod de_json(data, bot=None)

    See `telegram.TelegramObject.de_json()`.

  property decrypted_credentials
    Lazily decrypt and return credentials that were used

      to decrypt the data. This object also contains the user specified payload as decrypted_data.payload.

    Raises:

      telegram.error.PassportDecryptionError – Decryption failed. Usually due to bad private/public key but can also suggest malformed/tampered data.

    Type:

      `telegram.Credentials`

  property decrypted_data
    Lazily decrypt and return information

      about documents and other Telegram Passport elements which were shared with the bot.

    Changed in version 20.0: Returns a tuple instead of a list.

    Raises:

      telegram.error.PassportDecryptionError – Decryption failed. Usually due to bad private/public key but can also suggest malformed/tampered data.

    Type:

      tuple[`telegram.EncryptedPassportElement`]