skip to Main Content

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


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

    Login or Signup to reply.
  2. 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'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search