mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Update AutoAuthorization page
This commit is contained in:
parent
44f71f096f
commit
50ab50eb52
@ -14,27 +14,31 @@ Log In
|
|||||||
|
|
||||||
To automate the **Log In** process, pass your ``phone_number`` and ``password`` (if you have one) in the Client parameters.
|
To automate the **Log In** process, pass your ``phone_number`` and ``password`` (if you have one) in the Client parameters.
|
||||||
If you want to retrieve the phone code programmatically, pass a callback function in the ``phone_code`` field — this
|
If you want to retrieve the phone code programmatically, pass a callback function in the ``phone_code`` field — this
|
||||||
function must return the correct phone code as string (e.g., "12345") — otherwise, ignore this parameter, Pyrogram will
|
function accepts a single positional argument (phone_number) and must return the correct phone code (e.g., "12345")
|
||||||
ask you to input the phone code manually.
|
— otherwise, ignore this parameter, Pyrogram will ask you to input the phone code manually.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from pyrogram import Client
|
from pyrogram import Client
|
||||||
|
|
||||||
def phone_code_callback():
|
def phone_code_callback(phone_number):
|
||||||
code = ... # Get your code programmatically
|
code = ... # Get your code programmatically
|
||||||
return code # Must be string, e.g., "12345"
|
return code # e.g., "12345"
|
||||||
|
|
||||||
|
|
||||||
app = Client(
|
app = Client(
|
||||||
session_name="example",
|
session_name="example",
|
||||||
phone_number="39**********",
|
phone_number="39**********",
|
||||||
phone_code=phone_code_callback,
|
phone_code=phone_code_callback, # Note the missing parentheses
|
||||||
password="password" # (if you have one)
|
password="password" # (if you have one)
|
||||||
)
|
)
|
||||||
|
|
||||||
app.start()
|
app.start()
|
||||||
|
|
||||||
print(app.get_me())
|
print(app.get_me())
|
||||||
|
|
||||||
app.stop()
|
app.stop()
|
||||||
|
|
||||||
Sign Up
|
Sign Up
|
||||||
@ -44,23 +48,27 @@ To automate the **Sign Up** process (i.e., automatically create a new Telegram a
|
|||||||
``first_name`` and ``last_name`` fields alongside the other parameters; they will be used to automatically create a new
|
``first_name`` and ``last_name`` fields alongside the other parameters; they will be used to automatically create a new
|
||||||
Telegram account in case the phone number you passed is not registered yet.
|
Telegram account in case the phone number you passed is not registered yet.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from pyrogram import Client
|
from pyrogram import Client
|
||||||
|
|
||||||
def phone_code_callback():
|
def phone_code_callback(phone_number):
|
||||||
code = ... # Get your code programmatically
|
code = ... # Get your code programmatically
|
||||||
return code # Must be string, e.g., "12345"
|
return code # e.g., "12345"
|
||||||
|
|
||||||
|
|
||||||
app = Client(
|
app = Client(
|
||||||
session_name="example",
|
session_name="example",
|
||||||
phone_number="39**********",
|
phone_number="39**********",
|
||||||
phone_code=phone_code_callback,
|
phone_code=phone_code_callback, # Note the missing parentheses
|
||||||
first_name="Pyrogram",
|
first_name="Pyrogram",
|
||||||
last_name="" # Can be an empty string
|
last_name="" # Can be an empty string
|
||||||
)
|
)
|
||||||
|
|
||||||
app.start()
|
app.start()
|
||||||
|
|
||||||
print(app.get_me())
|
print(app.get_me())
|
||||||
|
|
||||||
app.stop()
|
app.stop()
|
Loading…
x
Reference in New Issue
Block a user