mtproto-core icon indicating copy to clipboard operation
mtproto-core copied to clipboard

Getting PHONE_CODE_INVALID in test environment

Open yashwanth2804 opened this issue 2 years ago • 4 comments

Error

{
  _: 'mt_rpc_error',
  error_code: 400,
  error_message: 'PHONE_CODE_INVALID'
}

Code

const api = require('./api')
const phoneNumber =  "+9996621958";
const delay = require('delay')
let code = '22222';
const nDc = async() => {
    //console.log(api.call('help.getConfig').then(s => console.log(s)) )
    const resp = await sendCode(phoneNumber);
    console.log(resp);
    try {
        
        delay(6000);
        const signUpq =await signUp(phoneNumber,resp.phone_code_hash);
        console.log(signUpq)
    } catch (error) {
        console.log(error)
    }


    
}
nDc();

function sendCode(phone) {
    return api.call('auth.sendCode', {
      phone_number: phone,
      settings: {
        _: 'codeSettings',
      },
    });
  }

 function signUp(  phone, phone_code_hash  ) {
     console.log(  phone, phone_code_hash )
    return api.call('auth.signUp', {
      phone_number: phone,
      phone_code:code,
      phone_code_hash: phone_code_hash,
      first_name: 'MTProto',
      last_name: 'Core',
    });
  }


but successfully got worked for sendCode

`response

{
  _: 'auth.sentCode',
  flags: 0,
  type: { _: 'auth.sentCodeTypeSms', length: 5 },
  phone_code_hash: 'a3b4dc965e02ac2586'
}

yashwanth2804 avatar Dec 17 '21 20:12 yashwanth2804

There is an error in the documentation. The code must be 6 characters long

alik0211 avatar Jun 23 '22 20:06 alik0211

still not working((( any idea?

smff avatar Dec 11 '22 11:12 smff

I can confirm that it's not working as it is returning PHONE_CODE_INVALID when using test environment.

And it has nothing to do with code being 6 characters long as signUp method is not working with the code, only the phone_code_hash

Can you please check?

goran-zdjelar avatar Feb 21 '23 08:02 goran-zdjelar

the same

VanillaTank avatar Aug 15 '23 08:08 VanillaTank