views:

828

answers:

2

According to http://github.com/facebook/python-sdk/blob/master/src/facebook.py , In my canvas application, i can do the following call to get my access_token, which will work because my user has used facebook to login:

import facebook 

myDict = facebook.get_user_from_cookie(cookies, app_id, app_secret)
# my access_token is myDict["access_token"]

myDict is alwas None, any ideas?

EDIT: I am running on app engine, By "canvas", i mean a facebook app which is ran inside of the facebook platform. Ie, it is'nt on my webiste, iphone or a desktop app. I realize that it is up to the javascript SDK to set the cookie, but to my understanding, if the application is running inside of facebook, then the cookies should allready be set.

+1  A: 

For this to work, you need to use the Javascript SDK to init the session at which point the python-sdk is able to read the cookies as set by the javascript-sdk.

Since you are using an IFrame canvas, the cookies set by facebook are not readable by you. In the python-sdk, there is a sample appengine oauth example that includes most of what you need to make it work.

user6738237482
A: 

In your facebook app, go to "Edit Settings" => "Migrations" and enable "Canvas Session Parameter". Now you can get the access token from request GET parameters. And, then use python-sdk to access graph API with the access token.

ashweta