miniproto.session.strings.export_session_string
miniproto.session.strings.export_session_string
Section titled “miniproto.session.strings.export_session_string”export_session_string(record_or_mapping: SessionRecord | Mapping[str, Any], *, format: Literal['miniproto', 'telethon', 'pyrogram'] = 'miniproto', passphrase: str | bytes | None = None, api_id: int | None = None, test_mode: bool | None = None) -> SessionStringExport a typed or decoded session record in a portable bearer format.
Parameters:
- record_or_mapping (
SessionRecord | Mapping[str, Any]) – A validated record or an already decoded record mapping. - format (
Literal[‘miniproto’, ‘telethon’, ‘pyrogram’]) – Nativeminiproto(default),telethonorpyrogram. - passphrase (
str | bytes | None) – Optional native-only authenticated encryption using scrypt and AES-256-GCM. - api_id (
int | None) – Required for Pyrogram when absent from record metadata. - test_mode (
bool | None) – Required for Pyrogram when absent from record metadata.
Returns:
SessionString– A bearer session string whosereprredacts its contents.
Raises:
SessionEnvelopeError– If data, authentication material, limits or format options are invalid.TypeError– If the input is neither a record nor mapping, or native export encounters an unsupported nested value.
A native passphrase protects the payload with scrypt and AES-256-GCM. Plain native, Telethon and Pyrogram outputs expose the contained bearer credentials. Use Client.export_session_string to export async storage. This function accepts already loaded state.