views:

369

answers:

1

Hello, I am building a Facebook canvas application that loads in an iframe with Django. I would like the login process to work similarly to the way Zynga does it. In this method, if you are not logged in you are redirected to a Facebook login page and then to a permissions request page for the app (without any popups).

As far as I can tell Zynga must be using FBML and just forwarding to URL's that look like:

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

Is there anyway to achieve a similar effect in a python app that loads in an iframe?

There is a method here that shows how to achieve the correct redirects using the new php sdk, but I am trying to use the new python SDK which only has the 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 some 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"&gt;&lt;/script&gt;
</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 it requires the user to click a button to login and then work through the popup authentication screens. (Note: a popup also occurs if I call FB.login directly)

So... is there a way to use the javascript SDK to redirect to the login page rather than loading it as a popup?

Thanks for any help! --Eric

A: 

I am struggling with similar problem. Have you found a solution for this? Any help appreciated.

Basically I want to use regular iframe (FBML is not an option) and do all the authentication using javascript only. I could do it by using FB.login, but it creates a popup. Since automatic popups are out of question and I don't want user to click on a button, I need something better. Facebook Authentication Doc says that I can use redirects, but it is no good, because my app sits inside an iframe (facebook canvas) and I can't redirect the parent window to https://graph.facebook.com/oauth/authorize for authz.

toomas008