Can't login to Facebook Canvas/Page Tab App #163

godshall opened this Issue Jul 4, 2012 · 2 comments

3 participants


I'm having difficulty logging into my Facebook app within Facebook (both Canvas and Page Tab). After authenticating with the application, it successfully creates a user and user profile in the backend, but the user's session does not seem to be authenticated because it takes them back to the home page to sign in again. What is strange is that I can login to the non-Facebook site using this same process, and it successfully logs me in and redirects me to the first page of the app. In addition, the issue has mainly been a problem with Internet Explorer 9, but I reproduced it one time on Mac Safari 5.1. Apart from that one Safari instance, it works successfully in Safari, Chrome, and Firefox.

Here are a few snippets from the logs that may help to identify the issue:

2012-07-04T21:38:15+00:00 app[web.1]: requesting access with redirect uri:, error was please authenticate
2012-07-04T21:38:15+00:00 app[web.1]: trying to convert the code with redirect uri:
2012-07-04T21:38:15+00:00 app[web.1]: Got code from the request data
...graph data...
2012-07-04T21:38:15+00:00 app[web.1]: force registration is set to None
2012-07-04T21:38:15+00:00 app[web.1]: facebook is authenticated
2012-07-04T21:38:16+00:00 app[web.1]: Django facebook performed action: django_facebook.connect.LOGIN

The only clear error is on the first line: "error was please authenticate" (the successful logs don't have this), but the end makes it look like the user was authenticated (even though they are not).

Here's my login form:

    <form id="facebookConnectForm" action="{% url facebook_connect %}?facebook_login=1" method="post">
            <button id="facebookConnectButton" class="landing-button">Start</button><br>
            <small style="font-size:11px;">Click START to get on your way</small>
            <input type="hidden" value="{% url trivia:index %}" name="register_next" />

Here are the urls to access both the Facebook app and the main site (use a zip code like 95257 to see login form):

Page Tab:
Canvas App:
Main Site:

I should also note that I'm not using the 'image' field from FacebookProfileModel because I don't need to save profile photos (following this #124). I don't think it would affect the issue at hand, but I just wanted to be thorough.

I'm extremely stuck on this issue and could use any help you can provide. Thanks in advance.


So after a lot of trial and error, I found people who were having problems with P3P headers in IE with other Facebook apps. See and for example. I found a Django snippet to inject P3P headers and it seems to be working in IE now. However, I didn't see anything about P3P headers in the Django-facebook docs, so I don't know if this is something unique to my setup, or if other people have experienced a similar issue.

Here's the middleware I'm using taken from

P3P_COMPACT = 'CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"' # I import this from a global constants file

class MiddlewareResponseInjectP3P(object):
    def __init__(self):
        self.process_response = self.inject

    def inject(self, request, response):
        response['P3P'] = P3P_COMPACT
        return response

Dear sir, you are an Internet hero. Thank you so much for finding that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment