social-app-django: Can't get Facebook Strict Mode to work
I’ve got the following message in my Facebook Dev console:
According to the information here https://developers.facebook.com/docs/facebook-login/security/#strict_mode strict mode is based on the exact redirect URL match. Unfortunately, I don’t think social-app-django uses this approach by default, because I can see several dynamic parameters in redirect URLs when I’m signing in with FacebookOAuth2
backend. Is anybody else experiencing the same problem?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18
facebook wrote in the documentation
In
class FacebookOAuth2(BaseOAuth2)
(version 1.5) we have unsetREDIRECT_STATE
attribute, which overridden as True which causeredirect_state
parameter in facebook complete url.1.7 is updated and now parameter is set by default:
REDIRECT_STATE = False
Actually it’s required to have a feature to rename this attribute in settings like:
SOCIAL_AUTH_FACEBOOK_REDIRECT_STATE_FIELD = 'state'
In my case allowed url was
https://<domain>/complete/facebook/
without additional parametersOverall, you can implement a custom
FacebookOAuth2
with onlyREDIRECT_STATE = False
as @merutak mentioned (for old versions).Or to update to the last version, other possible errors: missing web server https config + django configuration, this case a redirect url will be composed with
http
which will not pass a check.nginx
proxy_set_header X-Forwarded-Protocol $scheme;
django settings
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
Here is how I setup facebook auth in my settings file:
Valid OAuth redirect uri in Facebook dev console app settings:
The URL in Facebook dev console must match
redirect_uri
parameter of thehttps://www.facebook.com/v2.11/dialog/oauth...
URL.I didn’t want to upgrade python-social-auth. The only change I made eventually was this:
@IreliaCommitsU client_id is coming from your facebook api client settings. I don’t think there can be many of them.
Hi, I know this issue is closed but I didn’t understand the solution, So I just need to add this redirect URI to Facebook dev console app?
https://<domain>/complete/facebook/&client_id=<client_id>&return_scopes=true
What do I set for <client_id> if they are many and I can’tknow them all?
@rzinurov thank you, that helped me too. I was using an old version as well, which became evident when comparing your redirect_url scheme to mine.
@rzinurov Could you please be more specific. Our redirect URIs generated by social auth only contains
redirect_state
parameter in the query. We haven’t found a way to set up our application on facebook to pass the strict mode. Addition of theclient_id
andreturn_scopes
parameters doesn’t seem to help.