Telethon: test server configrution and breaking signin to two seperate step
hi i am new to telethon and i want to work with Test configuration. where do i must put DC address to go from Production to test?
also i have another problem , i want to build an api on top of telethon to let my another app login to telegram and receive data, so i need to do login step by step.
my first uri is register phone number : {
client = TelegramClient('sessions/'+api_hash, api_id, api_hash)
client.connect()
client.sign_in(phone)
}
my second method is confirm code : {
client = TelegramClient('sessions/'+api_hash, api_id, api_hash)
client.connect()
try:
me = client.sign_in(phone)
except Exception as e:
return jsonify({
"error": "-",
"success": False,
"message": str(e)
})
}
but always this error raise : Please make sure to call send_code_request first.
i saw telegram_client.py and look likes self._phone is None. what can i do ?
working environment : windows 10+python3
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (9 by maintainers)
Commits related to this issue
- More enhancements on .sign_in from different clients (#278) — committed to LonamiWebs/Telethon by Lonami 7 years ago
- Allow phone as int on .sign_in (#278) — committed to LonamiWebs/Telethon by Lonami 7 years ago
in file tlobject.py -> function serialize_bytes(data) -> line 93 data value is this : 989308645800 , its my phone number. len(data) in raise TypeError object of type ‘int’ has no length. phone number must be string 😕 , number is not valid , because len(data) is for string. so i changed my call to this :
me = client.sign_in(str(phone), code, None, None, tg_account.phone_code_hash)
and now its working 😃 thank you. i think its good to support numbers too. or raise error in top level to show a good error message.its an api , and yes script run every time a request made. i changed my branch to master, did you checked your solution? i get this error : “object of type ‘int’ has no len()”
what is the problem? before your solution i tried this and same error appeared :
client._phone = phone
client._phone_code_hash = tg_account.phone_code_hash
me = client.sign_in(phone, int(code), none, none, tg_account.phone_code_hash)