Reputation: 1
I am writing a program that creates Telegram accounts with the sign_up method provided by the telethon library. When I enter the code sent by the program to my phone it returns PhoneCodeInvalidError despite the code being valid.
from telethon import TelegramClient
async def main():
phone = '+390000000000'
await client.connect()
await client.send_code_request(phone)
code = input('enter code: ')
await client.sign_up(phone=phone, code=code, first_name="Anna")
if __name__ == '__main__':
client = TelegramClient('helohelohelo', 12345, abcdefghi)
client.loop.run_until_complete(main())
I've been looking for a solution everywhere, few people have talked about this problem and almost everything I have read had unclear resolution explanations.
Everything I've read about this issue: 1, 2, 3
Upvotes: 0
Views: 1441
Reputation: 3601
Any code sent over Telegram is immediately invalidated. Try putting spaces between each digit of the code.
Upvotes: 2