Provide REST API for authorizing telethon sessions
Add "django-telethon-authorization" to your INSTALLED_APPS setting:
INSTALLED_APPS = [ ... 'django_telethon_authorization', ]
Include django-telethon-authorization URL's in your project urls.py like this:
path('telegram-auth/', include('django_telethon_authorization.urls')),
Add environment variables:
- TG_API_ID = 111111
- TG_API_HASH = api_hash
- TG_SESSION_PATH = /path/to/sessions
Provide TG_SESSION_PATH only if you use SQLite as a session backend (Telethon default)
- Run python manage.py migrate to create the models.
- When you request a telegram code - TelegramAuthorization model will be created.
- It will be automatically linked to request.user
All endpoints accept JSON payloads.:: Usually response has status code 200 with a JSON.:: Each response contains boolean success property which indicates if request was successfull.:: If success == False -> variable message will be present inside JSON response with explanation.:
* POST /request_code/ * payload: {phone: <phone>} * POST /submit/ * payload: {phone: <phone>, code: <code>, password: <password>} * POST /logout/ * payload: {phone: <phone>}