mtproto-core
mtproto-core copied to clipboard
Getting PHONE_CODE_INVALID in test environment
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'
}
There is an error in the documentation. The code must be 6 characters long
still not working((( any idea?
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?
the same