I'm trying to receive long-lived access token from facebook.
I checked your codes, and found that this library can trade 'code' to 'access_token' in middleware, "OAuth2ForCanvasMiddleware".
But some codes, i don't understand.
elif 'code' in request.GET and 'facebook' in request.META.get('HTTP_REFERER', u''):
authenticate(request.REQUEST['code'], fb, application,
These codes call "authenticate" function. but the parameters not match.
function definition is like this.
def authenticate(app_id, app_secret, code=None, redirect_uri="", type=None):
and I found that sometimes there's no HTTP_REFERER so i can't check whether this request is from facebook, or not.
So those codes are not called.
I'm not good in python, but trying to hack your codes as i want to use.
can you give me any help, or some example django project using this library?
Shim, from Korea
This code is for the server side login flow.
To exchange an access token for the long-lived there is a new function in facebook.utils called do_exchange_token.
You have to use the 'structured' branch since that one is the current development branch.
Also make sure your configuration is correct as described in the docs (The docs on readthedocs are for the master branch. You have to build the docs for structured yourself, or just read the rst files).
I've not used 'structured' branch.
I'll try with it. thank you for your help.
I just updated the docs on the structured branch and added them to readthedocs:
This is really helpful.
Thank you! I'll read it now!