Closed farodrig closed 7 years ago
Are you sure you're using the code sent to that phone and not to your main phone?
Yes, I'm sure.
Using my app_ID and my app_hash provided by Telegram, I put the phone number of a friend sat next to me, he received the code in his phone and I put it in the client and responded me a code expired error.
I'm supposed to be able to do this, right?
I'm supposed to be able to do this, right?
Yes, it's really strange it doesn't work with a different phone number. Do you have other phone numbers to test this with? I presume that the computer you're working with has the right time zone and such? Sorry https://core.telegram.org/api/errors doesn't give much more information about PHONE_CODE_EXPIRED
.
Both people here and here mentioned it's a DC issue, but those should be handled gracefully already. Try changing the default one under session.py
in the Session
class? Maybe with the IP that api.telegram.org
shows?
@farodrig are you sending the code via Telegram to another account before using it?
yes!! It's that??
Yep, if you send an auth code via Telegram it expires automatically
Thank you @FrayxRulez :)
Confirmed on this, btw. As soon as I had a colleague send me the login code via WhatsApp, everything worked perfectly. Huge props to @FrayxRulez .
I had completely forgotten about this issue and it was discussed again recently on another Telegram API-related group. Closing #516.
@FrayxRulez How the code expires when sending through telegram?
It's a server-side check to prevent people from "accidentally" telling a possible attacker the code.
@Lonami Even in Secret Chats?Are only the particular users message validated ?
That feeling when you don't send code to anyone, and it is always expired... =/
That feeling when you don't send code to anyone, and it is always expired... =/
Can you solve the problem?
Yep, if you send an auth code via Telegram it expires automatically
Append zero with code to obscure it
That feeling when you don't send code to anyone, and it is always expired... =/
Can you solve the problem?
I added a letter before the code. for example if code is 12345 I send s12345 and that's work
Guys, I have the same issue !! How to fix it ?
I have a Telegram Bot that also use Telethon client for sing_in
?
When I provide a code to it I see that code is always expired !!
Guys, do you have solution ?
Guys, I have the same issue !! How to fix it ?
I have a Telegram Bot that also use Telethon client for
sing_in
? When I provide a code to it I see that code is always expired !!Guys, do you have solution ?
Me too. Got a solution?
When you logging in, you should write your code like a this one: "241 26", in other words - with spaces. But if you trying to log in with your own account and write code like 24126 (without spaces) - your code will be always expired
I was struggling for half a year with this particular error (PHONE_CODE_EXPIRED
) when trying to log in with my own account (other accounts could log in without any issues).
The solution? As @shakibm83 suggested above, I've added a single letter before the phone code number. And it works now. Just wow. Had to use another account all that time...
Thank you, @shakibm83!
Regards!
Maybe I misunderstand something completely - still having the same issue.
client.send_code_request(phone_number)
I don't obfuscate the code in any way so far, but also I wouldn't even have the possibility as the code is being sent upon client.send_code_request automatically, right?
I have both apps, the Telegram app and my custom app, on the same phone, so when I request the code in my custom app, I see the delivered code in the Telegram app notification (because of the new message from Telegram) and type it directly into my custom app, but then get the error "expired".
It applies both, to my real number as well as to the test numbers provided by Telegram (eg +99966XYYYY, depending on the test DC appointed in the API access data).
Interestingly, I had this issue in the beginning of development, then it somehow just worked and now it again doesn't work anymore.
Edit: Just noticed that it's a closed issue, will open a new one then.
I've got the same issue once again. Turns out it's very simple...the reason and the solution are explained here https://stackoverflow.com/questions/78591390/phone-code-expired-caused-by-auth-signin-error-during-authorization-using-node
Reason: Telegram security service watches your messages so whenever you try to send your one-time code (received via Telegram) to someone else via Telegram (even if you send to your own bot) the code is made invalid immediately (and reported as "expired", with an odd message from Telegram to your account telling you that your login attempt was unsuccessful and nobody gained access to your account). A probable explanation is that it's done to protect your account from hackers.
Solution:
Never send your one-time code as-is to your bot. Obfuscate the code when typing in a message to your bot (e.g. by putting letters between numbers 12345
-> 1a2a3a4a5
) and then deobfuscate by your bot. This way Telegram security service will not trigger and your one-time code will not "expire".
Regards!
Hi, when I tried to login with a phone different than the one I used in the telegram API registration, the client always send me a code expired message when I provide the code for the login.
I don't know if what I'm trying to do is not supported or what. This happen using the interactive telegram client. (I'm trying to login with a different number, providing the correct login code).
I hope someone could help me.
(I am not a native speaker, sorry for my english)