Log in with Facebook does not work

We’re trying to set up Facebook login by following this wik page: http://wiki.dreamfactory.com/DreamFactory/Tutorials/Using_OAuth

When doing POST https://your-url/api/v2/user/session?service=facebook, we’re getting back an HTML document instead of the JSON that is specified in the wiki. If we instead change the window.location.href to https://your-url/api/v2/user/session?service=facebook, it works and Facebook redirects us back with the authentication code. But now, if we do the second step, POST https://your-url/api/v2/user/session?oauth_callback=true&{extracted_query_string_from_callback}, we only get an error response saying that the required email parameter is missing.

I do not understand how the results can diverge so much from the wiki guide. Is it up to date? Are we doing something wrong? We’re using DF 2.3.1


Hi, did you manage to find the solution? I’m having exactly the same issue at the moment.

Yes, we did. I don’t remember the details and I don’t have the code here, but I’ll say what I remember. I think the solution was to extract the whole query string from the callback (everything after the question mark) and add that to the second step (not only the code parameter). I think we still used GET (changing window.location.href) on the first step.

Hope this helps. I’ll update if I find out more.

Oh, thanks, good to know there is some solution. I started an issue at github and turns out it should work the way I do it, given in the second POST you provide the state value received after the first request - that’s the way DF keeps track of the login internally. Other solution should be adding service=<service_name> to the second request to prevent DF from going the email/password path.

I see. Yes, I think when we included the whole query string instead of only the code, it also included the service parameter, which is probably why it worked for us in the end.

Are you experiencing problems like the following? Facebook login fails

Yes that was a part of the problem. But only a part. :slight_smile: The issue on github mentioned there is actually ‘my’ issue. I updated it with the solution that works for me.