views:

99

answers:

2

Hello, I'm writing a Django app requesting permission to post on facebook.

I can access authorization and callback, but I can't get the parameter 'code' that facebook needs to continue with oauth.

def connect_fb(request):
return redirect("https://graph.facebook.com/oauth/authorize?"
                +"client_id=MY_ID&"
                +"redirect_uri=MY_URL"
                +"&type=user_agent&display=popup&scope=publish_stream")

def callback_facebook(request):
code=request.REQUEST.get("code")

What's the right way to get 'code' so I can continue the oauth process? I tried several things but I keep getting None instead of a code.

Thanks

A: 

I've used django-facebook-oauth in the past, but if you really want to roll your own solution then I'd suggest just looking through their source.

From just glancing through it, the only thing I can see you doing differently is the

&type=user_agent&display=popup

in the URL. The app I linked you to doesn't appear to do that as far as I can tell.

Pewpewarrows
A: 

The problem comes from type=user_agent that is used in javascript authentication, and not here. Removing it allows to get code as above.