Canvas Facebook Authentication Using New Graphics API

I am creating a Facebook canvas application that loads in an iframe using Django. I would like the login process to work in the same way that Zynga does. In this method, if you are not logged in, you are redirected to the Facebook login page and then to the application permission page (without pop-ups).

As far as I can tell, Zynga should use FBML and just forward a URL that looks like this:

http://www.facebook.com/login.php?api_key=[api_key†&canvas=1&fbconnect=0&next=[return_url]

In any case, to achieve a similar effect in a python application loaded in an iframe?

There is a method here that shows how to achieve proper redirects using the new php sdk, but I'm trying to use the new python SDK, which only has a method:

def get_user_from_cookie(cookies, app_id, app_secret):
"""
Parses the cookie set by the official Facebook JavaScript SDK.
cookies should be a dictionary-like object mapping cookie names to
cookie values.
...
"""

I have a working code that uses the Javascript SDK and the get_user_from_cookie method:

<div id="fb-root">
 <script src="http://connect.facebook.net/en_US/all.js"></script>
</div>

<script type="text/javascript">
 FB.init({ apiKey: 'apikey', status: true, cookie: true, xfbml: true});

 FB.Event.subscribe('auth.login', function(response) {
  // Reload the application in the logged-in state
  window.top.location = 'http://apps.facebook.com/myapp/';
 });
</script>
<fb:login-button>Install MyApp</fb:login-button>

The problem with this method is that the user needs to click a button to log in, and then work with the pop-up authentication screens. (Note: a popup also appears if I call FB.login directly)

So ... is there a way to use the javascript SDK to redirect to the login page, and not to load it as a popup?

Thanks for any help! --Eric

+5
2

javascript SDK , ?

. JavaScript SDK , .

, https://graph.facebook.com/oauth/authorize?client_id={{ application_id }}&redirect_uri={{ redirect_uri }}. , , iframe, Facebook . , .

<!DOCTYPE html>

<!--
This document redirects the parent window to the authorization
dialog automatically, or falls back to a link if the client does not
support JavaScript.
-->

<html>
  <head>
    <script type="text/javascript">
      window.parent.location = 'https://graph.facebook.com/oauth/authorize?client_id={{ application_id }}&redirect_uri={{ redirect_uri }}';
    </script>
  </head>

  <body> 
    You must <a target="_top" href="https://graph.facebook.com/oauth/authorize?client_id={{ application_id }}&redirect_uri={{ redirect_uri }}">authorize this application</a> in order to proceed.
  </body>
</html>

, URI, redirect_uri, Facebook GET signed_request (. ), Facebook .

: ( - ) cookie , P3P; Internet Explorer cookie.

P3P: CP="IDC CURa ADMa OUR IND PHY ONL COM STA"

, Facebook, Django, . Fandjango, github.

+13

OAuth, Canvas Applications.

Python SDK, , example, .

0

All Articles