The api_id/api_hash combination is invalid

See original GitHub issue

It turns out that my script worked perfectly until I tried using it on another server, and from that moment on it stopped working and the error appears api_id / api_hash combination is invalid. I have checked api_id and hash_id many times, but they haven’t changed… so I would appreciate some help. Thanks.

Traceback (most recent call last):
  File "mytelegram.py", line 41, in <module>
    tclient.send_code_request(phone)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/telethon/telegram_client.py", line 241, in send_code_request
    result = self(SendCodeRequest(phone, self.api_id, self.api_hash))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/telethon/telegram_bare_client.py", line 486, in __call__
    result = self._invoke(call_receive, request, ordered=ordered)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/telethon/telegram_bare_client.py", line 583, in _invoke
    raise next(x.rpc_error for x in requests if x.rpc_error)
telethon.errors.rpc_error_list.ApiIdInvalidError: The api_id/api_hash combination is invalid

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

7reactions
kylethedevelopercommented, Mar 6, 2021

I actually figured it out. It was my fault I guess.

I created a bot account from BotFather and I was using my bot’s API token for all the variables; api_id, api_hash and bot_token. I did not realize that I had to use my api_id and api_hash for those variables. So to summarize:

api_id = <youraccount_api_id>
api_hash = <youraccount_api_hash>
bot_token = '123456789:apitoken_ofyourbot_thatyougetfrom_botfather'

I was actually going back and forth through the documentation and realized that I was wrong after reading TelegramClient page. In my opinion it should be mentioned on here too.

BTW both my own api_id and bot’s api_id are longer than 5 chars.

2reactions
Lonamicommented, Mar 6, 2021

The “here” you mention already says:

(at the top) Note: This API ID and hash is the one used by your application, not your phone number. You can use this API ID and hash with any phone number or even for bot accounts.

Signing In as a Bot Account […] You will still need an API ID and hash.

API ID, API hash, and bot token, all are different terms. But if you can improve the documentation, feel free to send a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"The Combination Is Invalid" Error When Loading Assignment ...
Goal. On : 11.13.19.01.0 version, Data Load "The combination is invalid" error when loading assignment with expense accounts.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found