cjongseok / mtproto

Telegram MTProto and its proxy (over gRPC) in Go (golang). API Layer: 71
Apache License 2.0
151 stars 20 forks source link

Error Classification #3

Closed Amin1012 closed 6 years ago

Amin1012 commented 6 years ago

Hi, Thanks for developing this mtproto library Can you help about classifying errors & responses? For example when using authSignIn how to determine the code was wrong or password was required?

cjongseok commented 6 years ago

Thanks for your interest in my code! I believe I've never seen kind of password in Telegram. On every new sign-in, it requires confirmation code sent through your Telegram account. You can check it on your Telegram mobile app. On a wrong confirmation code, Telegram server will send one of RPC error of 401 UNAUTHORIZED. AuthSignIn function will return the RPC error code on the sign-in failure. (I have just found there was a typo on the error string format, and fixed it.) See this Telegram API doc page for 401 UNAUTHORIZED examples.

Amin1012 commented 6 years ago

Thanks i use this code to catch errors when loading authentication file

        var er error
        color.HiMagenta("authentication file found")
        conn, er = manager.LoadAuthentication(phonenum, telegramAddress)
        color.HiMagenta("authentication file loaded")
        color.HiRed(er.Error())

every log before LoadAuthentication prints but no success on after , none of codes run correctly

cjongseok commented 6 years ago

LoadAuthentication() can create a MTProto session with authenticated credentials. So it only works after successful NewAuthentication(). If you didn't succeed to NewAuthentication(), let's try this first and see results. Or you can simply test whether your configuration works with my mtproto using mtproto/examples/simpleshell/simpleshell.go. I recommend to try it, because it is the best way to compare the development and testing environment with yours. You can run this with four parameters:

USAGE: go run simpleshell.go

APIID means Telegram API id. If you do not have it yet, go https://my.telegram.org/apps APIHASH means hashcode of . It is published together with API id. PHONE means signed-up phone number in international format w/o hyphen. e.g., +15417543010 ADDR means preferred Telegram server address in the form of :. You can find a valid address in your https://my.telegram.org/apps page.

cjongseok commented 6 years ago

And more information for your environment and mtproto configuration can boost up debugging. Please let me know your OS, go version, and whatever.

cjongseok commented 6 years ago

No response for a long time. If you still has an error after trying simpleshell.go, please re-open the issue.