Search code examples
pythontelegrampyrogram

How to register a pyrogram account


I'm trying to signup on telegram using pyrogram library

Here's the code I used

sc = app.send_code(phone_number = phone)

app.sign_up(
        phone_number = phone,
        phone_code_hash = code,
        first_name  = first_name,
        last_name = last_name
    )

I get below error

pyrogram.errors.exceptions.bad_request_400.PhoneCodeExpired: [400 PHONE_CODE_EXPIRED]


Solution

  • Firstly, you are registering telegram account not pyrogram account. Also, you should tell what variables you have.

    You forgot why you called send_code function in the first place.

    This would work

    sent_code = app.send_code(phone_number=phone)
    
    app.sign_up(
            phone_number = phone,
            phone_code_hash = sent_code.phone_code_hash,
            first_name  = first_name,
            last_name = last_name
    )