pyrofork icon indicating copy to clipboard operation
pyrofork copied to clipboard

[400 AUTH_BYTES_INVALID]

Open yourtulloh opened this issue 1 year ago • 0 comments

Checklist

  • [X] I am sure the error is coming from Pyrogram's code and not elsewhere
  • [X] I have searched in the issue tracker for similar bug reports, including closed ones
  • [X] I ran pip3 install -U https://github.com/Mayuri-Chan/pyrofork/archive/master.zip and reproduced the issue using the latest development version

Description

kemaren2 gak error begini tapi skrng sering muncul, pyrofork latest 2.3.11post2

Steps to reproduce

  1. userbot
  2. entah

Code example

from pyrogram import Client, utils, raw
from pyrogram.types import Message
from pyrogram.session import Session, Auth
from pyrogram.errors import AuthBytesInvalid,FloodWait

async def generate_media_session(self, client: Client, msg: Message):
        data = await self.generate_file_properties(msg)

        media_session = client.media_sessions.get(data.dc_id, None)

        if media_session is None:
            if data.dc_id != await client.storage.dc_id():
                media_session = Session(client, data.dc_id, await Auth(client, data.dc_id, await client.storage.test_mode()).create(), await client.storage.test_mode(), is_media=True)
                await media_session.start()

                for _ in range(5):
                    exported_auth = await client.invoke(raw.functions.auth.ExportAuthorization(dc_id=data.dc_id))

                    try:
                        await media_session.invoke(
                            raw.functions.auth.ImportAuthorization(
                                id=exported_auth.id,
                                bytes=exported_auth.bytes,
                            )
                        )
                    except AuthBytesInvalid:
                        continue
                    except FloodWait as e:
                        LOGGER.info(f"FloodWait when generate_media_session, value: {f.value}")
                        await asyncio.sleep(e.value)
                        await media_session.invoke(
                            raw.functions.auth.ImportAuthorization(
                                id=exported_auth.id,
                                bytes=exported_auth.bytes,
                            )
                        )
                    else:
                        break
                else:
                    await media_session.stop()
                    raise AuthBytesInvalid
            else:
                media_session = Session(client, data.dc_id, await client.storage.auth_key(), await client.storage.test_mode(), is_media=True)
                await media_session.start()

            client.media_sessions[data.dc_id] = media_session

        return media_session

Logs

Traceback (most recent call last):
  File "/venv/lib/python3.10/site-packages/pyrogram/client.py", line 1048, in get_file
    await session.invoke(
  File "/venv/lib/python3.10/site-packages/pyrogram/session/session.py", line 402, in invoke
    return await self.send(query, timeout=timeout)
  File "/venv/lib/python3.10/site-packages/pyrogram/session/session.py", line 359, in send
    RPCError.raise_it(result, type(data))
  File "/venv/lib/python3.10/site-packages/pyrogram/errors/rpc_error.py", line 91, in raise_it
    raise getattr(
pyrogram.errors.exceptions.bad_request_400.AuthBytesInvalid: Telegram says: [400 AUTH_BYTES_INVALID] - The authorization bytes are invalid (caused by "auth.ImportAuthorization")

yourtulloh avatar Nov 09 '23 18:11 yourtulloh