social-app-django icon indicating copy to clipboard operation
social-app-django copied to clipboard

Facebook login not working

Open veronicabasso opened this issue 8 years ago • 8 comments

I am using django 1.11 and followed the steps to enable Facebook login in my project. However, when I try to login I get the following error: Insecure Login Blocked: You can't get an access token or log in to this app from an insecure page. Try re-loading the page as https:// I have SSL certificate, and I can login using Google and twitter. I would be grateful if somebody can help me with this issue.

veronicabasso avatar Mar 22 '18 00:03 veronicabasso

I have the same issue after Facebook updated the "Use Strict Mode to Redirect URI". Here is the fix, add this to your settings : SOCIAL_AUTH_REDIRECT_IS_HTTPS = True

jackgoh avatar Mar 22 '18 05:03 jackgoh

@jackgoh, I added your code and still redirecting to http any other solution?

slimaidarismail avatar Mar 31 '18 10:03 slimaidarismail

I've just had this issue too. It occurs that my nginx configuration redirected from http to https but didn't forward protocol header. I've added proxy_set_header X-Forwarded-Proto $scheme; to my configuration and now it works properly.

pavelulyashev avatar Apr 20 '18 11:04 pavelulyashev

@pavelulyashev where should i put proxy_set_header X-Forwarded-Proto $scheme;

moshaabn avatar May 06 '18 16:05 moshaabn

@slimaidarismail To use HTTPS in your website, add the following in your project's settings.py file:

# Force https redirect
SECURE_SSL_REDIRECT = True
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Force HTTPS in the final URIs
SOCIAL_AUTH_REDIRECT_IS_HTTPS = True

The HTTPS won't work if the SSL certificate isn't installed on the server. Use Let's encrypt to install SSL certificate.

arjunthakur08 avatar May 10 '18 11:05 arjunthakur08

There is in the documentation[1] the parameter that solves the "problem" (not a problem), I think it is important to have reference on the Facebook[2] backend page (can link this issue as well)

What opinion of you?

[1] https://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html?highlight=SOCIAL_AUTH_REDIRECT_IS_HTTPS#processing-redirects-and-urlopen [2] https://python-social-auth-docs.readthedocs.io/en/latest/backends/facebook.html

avelino avatar Jun 02 '18 13:06 avelino

Try django sslserver https://github.com/teddziuba/django-sslserver it might help you.

nabeelayub avatar Mar 15 '19 16:03 nabeelayub

Try django sslserver https://github.com/teddziuba/django-sslserver it might help you.

YES, Django SSL server can solve it. I confirmed after got the same problem. But It can help for Facebook OAuth only if use JavaScript SDK still got the same problem!!

krabeeputh avatar Sep 27 '20 15:09 krabeeputh