mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Add AutoAuthorization page
This commit is contained in:
parent
ec7bf5d614
commit
c4b79d67cb
@ -18,7 +18,7 @@ Welcome to Pyrogram
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<b>Telegram MTProto API Client Library for Python</b>
|
<b>Telegram MTProto API Client Library for Python</b>
|
||||||
<br>
|
<br>
|
||||||
<a href="https://pypi.python.org/pypi/Pyrogram">
|
<a href="https://github.com/pyrogram/pyrogram/releases/latest">
|
||||||
Download
|
Download
|
||||||
</a>
|
</a>
|
||||||
•
|
•
|
||||||
@ -103,6 +103,7 @@ To get started, press Next.
|
|||||||
resources/UpdateHandling
|
resources/UpdateHandling
|
||||||
resources/ErrorHandling
|
resources/ErrorHandling
|
||||||
resources/ProxyServer
|
resources/ProxyServer
|
||||||
|
resources/AutoAuthorization
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:hidden:
|
:hidden:
|
||||||
|
60
docs/source/resources/AutoAuthorization.rst
Normal file
60
docs/source/resources/AutoAuthorization.rst
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
Auto Authorization
|
||||||
|
==================
|
||||||
|
|
||||||
|
Manually writing phone number, phone code and password on the terminal every time you want to login can be tedious.
|
||||||
|
Pyrogram is able to automate both **Sign-In** and **Sign-Up** processes, all you need to do is pass the relevant
|
||||||
|
parameters when creating a new Client.
|
||||||
|
|
||||||
|
Sign-In
|
||||||
|
-------
|
||||||
|
|
||||||
|
To automate the **Sign-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
|
||||||
|
function must return the correct phone code as string (e.g., "12345") — otherwise, ignore this parameter, Pyrogram will
|
||||||
|
ask you to input the phone code manually.
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from pyrogram import Client
|
||||||
|
|
||||||
|
def phone_code_callback():
|
||||||
|
code = ... # Get your code programmatically
|
||||||
|
return code # Must be string, e.g., "12345"
|
||||||
|
|
||||||
|
|
||||||
|
client = Client(
|
||||||
|
session_name="example",
|
||||||
|
phone_number="39**********",
|
||||||
|
phone_code=phone_code_callback,
|
||||||
|
password="password" # (if you have one)
|
||||||
|
)
|
||||||
|
|
||||||
|
client.start()
|
||||||
|
print(client.get_me())
|
||||||
|
|
||||||
|
Sign-Up
|
||||||
|
-------
|
||||||
|
|
||||||
|
To automate the **Sign-Up** process (i.e., automatically create a new Telegram account), simply fill **both**
|
||||||
|
*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.
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from pyrogram import Client
|
||||||
|
|
||||||
|
def phone_code_callback():
|
||||||
|
code = ... # Get your code programmatically
|
||||||
|
return code # Must be string, e.g., "12345"
|
||||||
|
|
||||||
|
|
||||||
|
client = Client(
|
||||||
|
session_name="example",
|
||||||
|
phone_number="39**********",
|
||||||
|
phone_code=phone_code_callback,
|
||||||
|
first_name="Pyrogram",
|
||||||
|
last_name="" # Can be an empty string
|
||||||
|
)
|
||||||
|
|
||||||
|
client.start()
|
||||||
|
print(client.get_me())
|
Loading…
x
Reference in New Issue
Block a user