Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[400 AUTH_BYTES_INVALID] #30

Open
3 tasks done
yourtulloh opened this issue Nov 9, 2023 · 0 comments
Open
3 tasks done

[400 AUTH_BYTES_INVALID] #30

yourtulloh opened this issue Nov 9, 2023 · 0 comments

Comments

@yourtulloh
Copy link

Checklist

  • I am sure the error is coming from Pyrogram's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • 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")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant