skip to Main Content

I’ve gotten to the point of sending the auth.sendCode method, with the following response:

('sentCode: ', {u'req_msg_id': 6324698204597889024L, u'result': {u'type': {u'len
gth': 5}, u'phone_registered': False, u'flags': 6, u'timeout': 120, u'next_type'
: {}, u'phone_code_hash': '52eb4ab096ea211b52'}})

This is using the telegram test servers. I have successfully used the same phone number in the telegram iPhone app and desktop application so I know the phone number is valid in production. (should it be valid on the test servers as well?)

When I follow auth.sendCode with auth.signIn I receive the following error response:

('authorization: ', {u'error_message': 'PHONE_NUMBER_UNOCCUPIED', u'error_code':
 400})

Is there a step between these two methods that registers the phone number?

3

Answers


  1. from https://core.telegram.org/api/auth

    The auth.sendCode method will also return the phone_registered field,
    which indicates whether or not the user with this phone number is
    registered in the system. If phone_registered == boolTrue,
    authorization requires that auth.signIn be invoked. Otherwise, basic
    information must be requested from the user and the new user
    registration method (auth.signUp) must be invoked.

    When phone_registered === boolFalse, the auth.signIn method can be
    used to pre-validate the code entered from the text message. The code
    was entered correctly if the method returns Error 400
    PHONE_NUMBER_UNOCCUPIED.

    Login or Signup to reply.
  2. If you are sure, that your phone is registered, then the reason of this error also could be wrong/incomplete TdLibParameters. That was the case for me in my android project. I ended up with following list, that worked:

        parameters.useTestDc = false
        parameters.databaseDirectory = appFolder
        parameters.filesDirectory = appFolder
        parameters.useFileDatabase = false
        parameters.useChatInfoDatabase = false
        parameters.useMessageDatabase = false
        parameters.useSecretChats = false
        parameters.apiId = 1111
        parameters.apiHash = "1111"
        parameters.systemLanguageCode = Locale.getDefault().isO3Language
        parameters.deviceModel = Build.MODEL
        parameters.systemVersion = Build.VERSION.RELEASE.toString()
        parameters.applicationVersion = "0.1"
        parameters.enableStorageOptimizer = true
        parameters.ignoreFileNames = true
    
    Login or Signup to reply.
  3. Have a look into this page . So the production phone registration does not apply to test_dc.

    As per the explantion on that page:

    use “auth.signUp” instead “auth.signIn”

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search