"Bot domain invalid" error in web telegram login. Django

Viewed 261

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

Since Django 4.0 you can use Cross-Origin Opener Policy instead of removing security middleware.

Tested on Django 4.1:

SECURE_CROSS_ORIGIN_OPENER_POLICY = 'same-origin-allow-popups'

You have to contact @BotFather on Telegram and set use the /setdomain command to allow logins to your bot from your domain.

Related