alik0211 / mtproto-core

Telegram API JS (MTProto) client library for Node.js and browser
https://mtproto-core.js.org
GNU General Public License v3.0
630 stars 113 forks source link

Getting PHONE_CODE_INVALID in test environment #228

Open yashwanth2804 opened 2 years ago

yashwanth2804 commented 2 years ago

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', { phonenumber: 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' }

alik0211 commented 2 years ago

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

smff commented 1 year ago

still not working((( any idea?

goran-zdjelar commented 1 year ago

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?

VanillaTank commented 1 year ago

the same