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

102 Unknown error while getting Access Token: Unprocessable Entity #58

Closed
VasNick8064 opened this issue May 23, 2024 · 8 comments
Closed

Comments

@VasNick8064
Copy link

| ERROR    | 85 - tesssst | Unknown error during Authorization: database is locked
| ERROR    | 102 - tesssst | Unknown error while getting Access Token: 422, message='Unprocessable Entity', url=URL('https://api.hamsterkombat.io/auth/auth-by-telegram-webapp') | Response text: {"type":"validation","on":"body","found":{"initDataRaw":null,"fingerprint":{}}}
| ERROR    | 102 - tesssst | Unknown error while getting Access Token: 422, message='Unprocessable Entity', url=URL('https://api.hamsterkombat.io/auth/auth-by-telegram-webapp') | Response text: {"type":"validation","on":"body","found":{"initDataRaw":null,"fingerprint":{}}}
| ERROR    | 102 - tesssst | Unknown error while getting Access Token: 422, message='Unprocessable Entity', url=URL('https://api.hamsterkombat.io/auth/auth-by-telegram-webapp') | Response text: {"type":"validation","on":"body","found":{"initDataRaw":null,"fingerprint":{}}}
 | ERROR    | 102 - tesssst | Unknown error while getting Access Token: 422, message='Unprocessable Entity', url=URL('https://api.hamsterkombat.io/auth/auth-by-telegram-webapp') | Response text: {"type":"validation","on":"body","found":{"initDataRaw":null,"fingerprint":{}}}
@efsfssf
Copy link

efsfssf commented Jun 3, 2024

2024-06-04 00:00:32 | ERROR | 90 - ds| Unknown error during Authorization: Telegram says: [406 CHANNEL_PRIVATE] - The channel/supergroup is not accessible (caused by "channels.GetMessages")
2024-06-04 00:00:36 | ERROR | 106 - ds | Unknown error while getting Access Token: 422, message='Unprocessable Entity', url=URL('https://api.hamsterkombat.io/auth/auth-by-telegram-webapp') | Response text: {"type":"validation","on":"body","found":{"initDataRaw":null,"fingerprint":{"fingerprint":{"version":"4.2.1","visitorId":"c5346e.

@joden95
Copy link

joden95 commented Jun 4, 2024

2024-06-04 11:59:35 | ERROR | 90 - new_hamster| Unknown error during Authorization: Telegram says: [401 AUTH_KEY_UNREGISTERED] - The key is not registered in the system. Delete your session file and login again (caused by "messages.GetDialogs")
2024-06-04 11:59:38 | ERROR | 106 - new_hamster| Unknown error while getting Access Token: 422, message='Unprocessable Entity', url=URL('https://api.hamsterkombat.io/auth/auth-by-telegram-webapp') | Response text: {"type":"validation","on":"body","found":{"initDataRaw":null,"fingerprint":{"fingerprint":{"version":"4.2.1","visitorId":"92ef02...

Does anyone know what could be causing this error? The session was deleted and created again from scratch. Still this error
(можно на русском отвечать, если кто знает)

@shamhi
Copy link
Owner

shamhi commented Jun 4, 2024

do you use last update?

@joden95
Copy link

joden95 commented Jun 4, 2024

Yes, but to make sure that at the time of writing your question I had the latest version, I completely deleted all data about your bot from my computer. I downloaded all the files completely from start to finish, updated the dependencies, api and tokens, but I still have this error
Screenshot_2

@shamhi
Copy link
Owner

shamhi commented Jun 4, 2024

read the first error, your session is invalid, recreate it

@shamhi shamhi closed this as completed Jun 4, 2024
@GibMeMyPacket
Copy link

GibMeMyPacket commented Jun 4, 2024

@shamhi Hey, getting kinda the same error

Attaching to HamsterKombatBot
HamsterKombatBot  | 2024-06-04 19:00:46 | INFO     | 70 - Detected 1 sessions | 1 proxies
HamsterKombatBot  | 2024-06-04 19:00:47 | INFO     | 303 - test | Proxy IP: xx.xx.xx.xx
HamsterKombatBot  | 2024-06-04 19:00:48 | ERROR    | 90 - test | Unknown error during Authorization: Telegram says: [400 BOT_METHOD_INVALID] - The method can't be used by bots (caused by "messages.GetDialogs")
HamsterKombatBot  | 2024-06-04 19:00:53 | ERROR    | 106 - test | Unknown error while getting Access Token: 422, message='Unprocessable Entity', url=URL('https://api.hamsterkombat.io/auth/auth-by-telegram-webapp') | Response text: {"type":"validation","on":"body","found":{"initDataRaw":null,"fingerprint":{"fingerprint":{"version":"4.2.1","visitorId":"xxxx...

The error only exists when using BOT Token (BotFather) instead of providing number and login code.

using the latest version and commit (7c480d1)

@GibMeMyPacket
Copy link

@shamhi Another kind of error that stops the bot:

HamsterKombatBot  | 2024-06-04 19:42:04 | INFO     | 485 - test | Minimum energy reached: 0
HamsterKombatBot  | 2024-06-04 19:42:04 | INFO     | 486 - test | Sleep 1,004s
HamsterKombatBot  | socket.send() raised exception.
HamsterKombatBot  | socket.send() raised exception.
HamsterKombatBot  | [10] Retrying "updates.GetChannelDifference" due to: Connection lost
HamsterKombatBot  | socket.send() raised exception.
HamsterKombatBot  | Task exception was never retrieved
HamsterKombatBot  | future: <Task finished name='Task-1056' coro=<Client.handle_updates() done, defined at /usr/local/lib/python3.10/site-packages/pyrogram/client.py:535> exception=OSError(ConnectionResetError('Connection lost'))>
HamsterKombatBot  | Traceback (most recent call last):
HamsterKombatBot  |   File "/usr/local/lib/python3.10/site-packages/pyrogram/client.py", line 567, in handle_updates
HamsterKombatBot  |     diff = await self.invoke(
HamsterKombatBot  |   File "/usr/local/lib/python3.10/site-packages/pyrogram/methods/advanced/invoke.py", line 79, in invoke
HamsterKombatBot  |     r = await self.session.invoke(
HamsterKombatBot  |   File "/usr/local/lib/python3.10/site-packages/pyrogram/session/session.py", line 412, in invoke
HamsterKombatBot  |     return await self.invoke(query, retries - 1, timeout)
HamsterKombatBot  |   File "/usr/local/lib/python3.10/site-packages/pyrogram/session/session.py", line 412, in invoke
HamsterKombatBot  |     return await self.invoke(query, retries - 1, timeout)
HamsterKombatBot  |   File "/usr/local/lib/python3.10/site-packages/pyrogram/session/session.py", line 412, in invoke
HamsterKombatBot  |     return await self.invoke(query, retries - 1, timeout)
HamsterKombatBot  |   [Previous line repeated 7 more times]
HamsterKombatBot  |   File "/usr/local/lib/python3.10/site-packages/pyrogram/session/session.py", line 402, in invoke
HamsterKombatBot  |     raise e from None
HamsterKombatBot  |   File "/usr/local/lib/python3.10/site-packages/pyrogram/session/session.py", line 389, in invoke
HamsterKombatBot  |     return await self.send(query, timeout=timeout)
HamsterKombatBot  |   File "/usr/local/lib/python3.10/site-packages/pyrogram/session/session.py", line 340, in send
HamsterKombatBot  |     raise e
HamsterKombatBot  |   File "/usr/local/lib/python3.10/site-packages/pyrogram/session/session.py", line 337, in send
HamsterKombatBot  |     await self.connection.send(payload)
HamsterKombatBot  |   File "/usr/local/lib/python3.10/site-packages/pyrogram/connection/connection.py", line 69, in send
HamsterKombatBot  |     await self.protocol.send(data)
HamsterKombatBot  |   File "/usr/local/lib/python3.10/site-packages/pyrogram/connection/transport/tcp/tcp_abridged.py", line 38, in send
HamsterKombatBot  |     await super().send(
HamsterKombatBot  |   File "/usr/local/lib/python3.10/site-packages/pyrogram/connection/transport/tcp/tcp.py", line 104, in send
HamsterKombatBot  |     raise OSError(e)
HamsterKombatBot  | OSError: Connection lost
HamsterKombatBot  | 2024-06-04 19:58:48 | INFO     | 507 - Sleep 52s
HamsterKombatBot  | 2024-06-04 19:59:40 | ERROR    | 106 - test | Unknown error while getting Access Token: Session is closed | Response text: ...

Restarting the docker container (docker compose restart) simply fixes it!
I guess in such cases, in some environments (e.g. Docker) it's better to exit the bot completely so Docker will automatically start it again and the error is disappeared (this is a quick fix if handling all the errors correctly takes time to implement). Maybe a boolean environment variable like EXIT_ON_ERROR or such.

@ButCheR-PRO ButCheR-PRO changed the title Unprocessable Entity 102 Unknown error while getting Access Token: Unprocessable Entity Jun 6, 2024
@ButCheR-PRO
Copy link
Collaborator

ButCheR-PRO commented Jun 18, 2024

Don't confuse API_HASH with the bot token. Where do you get the bot token?
Alternatively, instead of a token, enter the phone number in international format to which your Telegram account is linked, a code will be sent there, paste this code into the bot and everything will work.

Problem solution:

  1. Log in to this telegram account from any device;
  2. Close all sessions with the Pyrogram header
  3. Recreate the session inside your bot (instead of a token, use a phone number in international format)
  4. Disable proxy or use SOCKS5 instead of HTTP
  5. Synchronize the system time on your computer

See also:

  1. [Возможный фикс (не кода)] ошибок 406 и 422 message='Unprocessable Entity' #309
  2. 422 Unknown error while getting Profile Data: message='Unprocessable Entity' #38
  3. 102 Unknown error while getting Access Token: Unprocessable Entity #58
  4. 422 Unknown error while getting Access Token Unprocessable Entity, NoneType pbject has no attribute - Проблема с PROXY.  #86
  5. Не работает авторизация через токен bot - Unknown error while getting Access token 422: Unprocessable Entity #137
  6. Unknown error while getting Access Token: 422, message='Unprocessable Entity' #263

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

6 participants