5

While running my first code using Telethon library, it is asking for a bot token.

This is the actual code:

from telethon import TelegramClient, events, sync
api_id = 1234567
api_hash = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
client = TelegramClient('anon', api_id, api_hash)
client.start()

And on command prompt:

pip3 install telethon

python3 C:/TG/First.py

Result:

Please enter your phone (or bot token)

If I give my API ID, it eventually throws the error:

telethon.errors.rpcerrorlist.PhoneNumberInvalidError: The phone number is invalid (caused by SendCodeRequest)

Why? I expect the client to start without errors.

PS: my API ID is 7 digits long.

Arcones
  • 3,954
  • 4
  • 26
  • 46
Aneesh M
  • 53
  • 1
  • 1
  • 4

3 Answers3

2

This will only occure at your first use just enter your Phone Number starting with + then you will recive a code which you have to enter next. This is just to Authorise your Laptop beeing loged in to Telegram.

zoozle
  • 21
  • 2
0

As the error message suggests, your phone number is invalid. Maybe you didn't enter it in international format?

Hack5
  • 3,244
  • 17
  • 37
  • I am so stupid. I was entering API ID instead of phone number when it clearly says enter phone. I thought API ID is something like a phone number but for the software. Thank you very much. – Aneesh M Nov 10 '19 at 17:06
0

I think you are giving your API ID, but it is asking for your phone number in international format like +91xxxxxxxxxx

Michael Halim
  • 262
  • 2
  • 20