telegram-s / telegram-api-old

Telegram Api library for java
MIT License
138 stars 64 forks source link

Phone code is always expired #39

Closed tapule closed 8 years ago

tapule commented 8 years ago

I'm trying to make some test with this library and, although I can get the SMS code, the call to authSingIn always says that the SMS code expired. The phone number I'm using is already registered, so first I call authSendCode to get the phone hash and the SMS Code and then I call authSingIn to validate the phone, but always the same response:

MTProto#1001#Transport5:Start reading message: pre
MTProto#1001#Transport5:Start reading message: 104
MTProto#1001:MTProtoMessage: future_salts#ae500895
MTProto#1001#Scheduller:Forgetting message: #17
ActorDispatcher:Dispatching action: new for response
MTProto#1001:MTProtoMessage: rpc_result#f35c6d01
MTProto#1001:rpc_result: 6195499266601910288
TelegramApi#1001:<< #1 error #400 PHONE_CODE_EXPIRED in 648 ms
MTProto#1001#Scheduller:Forgetting message: #16
public TLAuthorization authSignIn(String phoneNumber, String phoneHash, String code) {
        try {
            TLAuthorization authorization = api.doRpcCallNonAuth(new TLRequestAuthSignIn(phoneNumber, phoneHash, code));
            api.getState().setAuthenticated(api.getState().getPrimaryDc(), true);
            return authorization;
        } catch(RpcException e) {
            if(e.getErrorCode() == 303) {
                String split[] = e.getErrorTag().split("_");
                int destDC = Integer.parseInt(split[split.length - 1]);
                api.switchToDc(destDC);
                return authSignIn(phoneNumber, phoneHash, code);
            }
            else
            {
                logger.info("===> " + e.getErrorCode() + " - " + e.getErrorTag());
            }
        } catch(IOException e) {}

        return null;
    }

Please can anyone help me??

Raakh commented 8 years ago

tapule can you send me complete working example? My email is 106597@gmail.com

tapule commented 8 years ago

Thank you Raakh, but I solved the problem. My connection was not to the correct DC.

Raakh commented 8 years ago

Dear tapule, Can you please send me your working code example? I shall be grateful to you. My skype id is Ghayel_

Can you please talk to me?