Closed leonerd closed 5 years ago
How exactly do you record a phone number?
A plain string containing just decimal digits. No leading +, no spaces or parens or other strange characters.
I have reduced this down to a minimal test case:
"use strict";
var MTProto = require("telegram-mtproto").MTProto;
var number = process.argv[2];
console.log("Calling auth.sendCode on number=" + number);
var APP = {
id: "57582",
hash: "7e085c887f71c9f1480c3930547ac159",
};
var client = MTProto({
layer: 57,
api_id: APP.id,
});
client("auth.sendCode", {
phone_number: number,
current_number: true,
api_id: APP.id,
api_hash: APP.hash,
}).then((result) => {
console.log("sendCode succeeded:", result);
process.exit(0);
});
Running this on different phone numbers yields:
$ nodejs test-issue49.js 4477xxxxxxxx
Calling auth.sendCode on number=4477xxxxxxxx
sendCode succeeded: { _: 'auth.sentCode',
flags: 3,
phone_registered: true,
type: { _: 'auth.sentCodeTypeApp', length: 5 },
phone_code_hash: 'XXX...,
next_type: { _: 'auth.codeTypeSms' } }
$ nodejs test-issue49.js 131xxxxxxxx
Calling auth.sendCode on number=131xxxxxxxx
[6.874] Error 401 AUTH_KEY_EMPTY 2 4
[7.090] Error 401 AUTH_KEY_UNREGISTERED 2 4
If I purposely remove a digit from the phone number and type it short, I get
$ nodejs test-issue49.js 131xxxxxx
Calling auth.sendCode on number=131xxxxxx
[9.364] Error 400 PHONE_NUMBER_INVALID 2 4
So I definitely get the feeling this is somehow related to the specific number I used.
I'm disinclined to paste the full phone numbers here in public github but I'd be happy to email them privately so you could re-test locally yourself. The actual number was just copypasted directly out of a working web Telegram client.
For comparison, I managed to authenticate successfully as this (failing) phone number when using web.telegram.org; I'm currently writing a similar test script to theabove using telegram.link
to see if it works there too
@leonerd I am @zerobias in telegram, or you can send email ribkatt@gmail.com
Also, which version is used?
@leonerd I am @zerobias in telegram
I've just sent you a message then.
Also, which version is used?
Currently testing against my fork, https://github.com/leonerd/telegram-mtproto/tree/leonerd/emit-raw-updates which is equal to your current master
branch plus a single-line patch in the incoming message path, to emit()
them as events. I don't imagine that will make any difference, but for completeness I'll swap it back to your master branch just to be sure.
for completeness I'll swap it back to your master branch just to be sure.
Indeed; makes no difference running on the master
upstream branch; which is 7084e5e
After much back-and-forth with @zerobias on Telegram, I now have a local test script that works with both numbers. I'll see if I can extract a minimum diff between that and the non-working.
OK; it seems that actually the main difference is that it works against the @3.0.5-unstable
version of telegram-mtproto
but not the stable version you get from a regular npm install
. The new version does need adjusted code to drive it, but said code fails the same way on stable version.
For reference:
$ npm install telegram-mtproto@3.0.5-unstable
Then
"use strict";
var MTProto = require("telegram-mtproto").MTProto;
var number = process.argv[2];
console.log("Calling auth.sendCode on number=" + number);
var APP = {
id: 57582,
hash: "7e085c887f71c9f1480c3930547ac159",
version: "0.0.1",
lang: "en",
};
var client = MTProto({
api: {
layer: 57,
api_id: APP.id,
app_version: APP.version,
lang_code: APP.lang,
},
server: {
webogram: true,
dev: false,
},
});
client("auth.sendCode", {
phone_number: number,
current_number: true,
api_id: APP.id,
api_hash: APP.hash,
}).then((result) => {
console.log("sendCode succeeded:", result);
process.exit(0);
});
works on all of my test numbers.
Use version 3.2.11 npm i -S telegram-mtproto@alpha
I have the same issue with several US based phone numbers. I tried several different versions of telegram-mtproto including 3.2.11. Earlier versions result in AUTH_KEY_EMPTY. In 3.2.11, there is no error but also no results. The promise for auth.sendCode never returns.
main [event] 5.485 +0ms
main { data: <Buffer 00 00 00 00 00 00 00 00 01 90 c1 d2 34 67 a1 5a 34 00 00 00 34 f7 cb 3b 53 db 37 84 e5 b2 e2 88 10 90 83 b5 47 79 00 90 aa 42 93 f4 9a de 8e 0d 21 df ... >,
main status: 200,
main statusText: 'OK' } +0ms
tl:reader [int] 5.486 +0ms
tl:reader client_dh[id] 1003222836 +0ms
tl:read [int bytes] 5.486 +0ms
tl:read 53db3784e5b2e288109083b547790090 client_dh[dh_gen_ok][nonce]:int128 +0ms
tl:read [int bytes] 5.486 +0ms
tl:read aa4293f49ade8e0d21dfd56e2b21f705 client_dh[dh_gen_ok][server_nonce]:int128 +0ms
tl:read [int bytes] 5.486 +0ms
tl:read 7328b8e9eb0ad44109220361ff760e1f client_dh[dh_gen_ok][new_nonce_hash1]:int128 +0ms
auth [Got Set_client_DH_params_answer] 5.487 +0ms
auth dh_gen_ok +0ms
I've tested different variations of code, including @leonerd's snippet above. No luck on any of them.
Webogram works just fine.
Let me know if there are any more details I can provide to help debug this.
Any luck with that one, @simple10 ?
I have found a workaround for those US based phone numbers! Use a VPN. For example, I conncted to US - Miami in hide.me VPN. After that, US based phone numbers worked. I am using the version 3.2.11.
Same server/code/etc... that works on some phone numbers (e.g. "+4477xxxxx") fails to work with others (e.g. "+131...")
This is still with code that forces
on the
auth.sendCode
call. Without forcingdcID
, the code still prints an error messagebut the returned promise never completes, just spins away into the void...