LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!
https://docs.telethon.dev
MIT License
9.43k stars 1.35k forks source link

send_code_request not working #4047

Closed Dantekk closed 1 year ago

Dantekk commented 1 year ago

This is my code :

from telethon.sync import TelegramClient

api_id = .....
api_hash = ......

client = TelegramClient("session_name", api_id, api_hash)

async def main():
    await client.connect()
    phone_number = "+34xxxxxxxxx"
    client.send_code_request(phone_number, force_sms=True)
    verification_code = input("Add code : ")
    client.sign_up(verification_code, first_name="joe", last_name="smith")

    await client.disconnect()

client.loop.run_until_complete(main())

I got this errore message in send_code_request() function :

telethon.errors.rpcerrorlist.SendCodeUnavailableError: Returned when all available options for this type of number were already used (e.g. flash-call, then SMS, then this error might be returned to trigger a second resend) (caused by ResendCodeRequest)

I don't know what is the problem... I have tried a lot of different number but I always got the same error, meanwhile sign_in() function working very well.

Lonami commented 1 year ago

Telegram sent this message to those with an API ID and hash:

Telegram API Update. Hello —,. Thank you for contributing to the open Telegram ecosystem by developing your app, —.

Please note that due to recent updates to Telegram's handling of SMS and the integration of new SMS providers like Firebase, we are changing the way login codes are handled in third-party apps based on the Telegram API.

Starting on 18.02.2023, users logging into third-party apps will only be able to receive login codes via Telegram. It will no longer be possible to request an SMS to log into your app – just like when logging into Telegram's own desktop and web clients.

Exactly like with the Telegram Desktop and Web apps, if a user doesn’t have a Telegram account yet, they will need to create one first using an official mobile Telegram app.

We kindly ask you to update your app’s login and signup interfaces to reflect these changes before they go live on 18.02.2023 at 13:00 UTC.

This change will not significantly affect users since, according to our research, the vast majority of third-party app users also use official Telegram apps. In the coming months, we expect to offer new tools for third-party developers that will help streamline the login process.

In short, SMS login or sign up will no longer work in third-party libraries, including Telethon. This cannot be "fixed".

Lonami commented 1 year ago

Also duplicate of #3835, which was even pinned.