I am using django framework with python-social-app and have an error while trying to login with Facebook login button.
My app consists of three docker containers:
Here is my error:
Authentication process canceled: URL Blocked: This redirect failed because the redirect URI is not whitelisted in the app’s Client OAuth Settings. Make sure Client and Web OAuth Login are on and add all your app domains as Valid OAuth Redirect URIs. Blockquote
and here is the URL that i can see while trying to login
https://www.facebook.com/v2.9/dialog/oauth?client_id=247739632734206&redirect_uri=http%3A%2F%2Fwww.DOMAN_NAME.com%2Fcomplete%2Ffacebook%2F&state=7AySpKwDWAKtiIxP75LBIPqwQNWSu36y&return_scopes=true
The problem, as i can see it, is that redirect_uri starts with HTTP and not with HTTPS.
Django==2.2
social-auth-app-django==3.1.0
social-auth-core==3.1.0
My best guess about the problem is that Django app don't "know" that it's running behind the NGINX+SSL and generates the redirect_uri with HTTP protocol instead of HTTPS.
Facebook settings has correct redirect URI that starts with HTTPS. The problem is not specific to Facebook, redirect_uri for Google has the same problem.
How can I force the python-social to to use HTTPS?
What you should be looking for is to add below line in the settings.py of your Django App.
SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
This way redirect_uri created by django social contain https.
As per the above answer what you did instead is redirected the http traffic to https which will still be an issue if you're trying to create an https only server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With