tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.07k stars 1.44k forks source link

Authorization without SMS #635

Closed stanleyG123 closed 5 years ago

stanleyG123 commented 5 years ago

Looks like the authorization flow requires a phone number and an SMS. Is there a way to get authorized without an SMS on each session? Perhaps by providing an API key of some sort?

thanks !!

levlam commented 5 years ago

Unless you are using a bot account, you need to enter authentication code to be able to use Telegram. Authentication code is usually sent by SMS, but server may choose other ways to verify your phone number and deliver authentication code to the user. See AuthenticationCodeType documentation for more details about the method by which an authentication code can be delivered to the user.

stanleyG123 commented 5 years ago

Thank you Aleksey, Just to confirm , there is no way to get "pre-authorised" and use the key for follow on sessions ?

I'm trying to use TDlib in server side code and getting SMS re-authorization won't work for me. How do other libraries such as Telethon and Python libraries do it? They all probably come in through bot APIs.

levlam commented 5 years ago

There is no way to get "pre-authorized key", but the session is saved automatically as in any other client, so you need to authorize only once.

stanleyG123 commented 5 years ago

Does it time out after some time or inactivity ? Where can I learn more about this ?

thanks again for your time !

levlam commented 5 years ago

The account will be automatically deleted after 6 months of inactivity by default.

stanleyG123 commented 5 years ago

"...but the session is saved automatically as in any other client..." Are you talking about sqlite .session files? I built a quick test with Telethon ( Python) and it saves .session files so I can restart my program several times

When I try the java example, the sequence is the same : 1. AuthorizationStateWaitTdlibParameters , 2.AuthorizationStateWaitEncryptionKey 3. AuthorizationStateWaitPhoneNumber

I am ok doing it once and storing a key in some cache and then reusing for the duration of the session like it is in Telethon.

I apologize if asking dumb questions , and thank you for your time.

levlam commented 5 years ago

See https://core.telegram.org/tdlib/getting-started#user-authorization for user authorization workflow documentation. All session data is saved by TDLib automatically in database_directory provided by the application.

stanleyG123 commented 5 years ago

thanks !!

nonlin-lin-chaos-order-etc-etal commented 4 years ago

There is a checkAuthenticationBotToken function for this: https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1check_authentication_bot_token.html

levlam commented 4 years ago

@nonlinear-chaos-order-etc-etal The method is for bots only. Ordinary users can't log in without having a phone number.