When integrating the login via telegram for Django, I received the following error (despite the fact that all actions were done correctly)
Bot domain invalid error
I’ve been tinkering with this for a couple of days and just want to share a solution.
The solution is simple and pretty funny.
Just remove
"django.middleware.security.SecurityMiddleware"
from MIDDLEWARE
2
Answers
You have to contact @BotFather on Telegram and set use the
/setdomain
command to allow logins to your bot from your domain.Since Django 4.0 you can use Cross-Origin Opener Policy instead of removing security middleware.
Tested on Django 4.1: