facebook App: Logon and requests with Python <p>I am creating a Facebook App, but am having a lot of trouble with the logon. I need to be able to access people's basic public information, such as their friends. I am coding in Django/Python.</p> <p>I tried an example using @facebook.require_login. That allows a person to add the app and give the basic permissions, however, once the person is logged on, I am not able to make requests; I need an access token and don't know how to get it.</p> <p>I tried following the authentication described here: <a href="http://developers.facebook.com/docs/authentication" rel="nofollow">http://developers.facebook.com/docs/authentication</a>. That seems to work for a stand-alone website where the person logs in each time: I am brought to the log-in page, allowed to log-in, and can then get a 'code' for further use. But, as it is a Facebook App, the person will already be logged in when they click on the App. In fact, when I tried this via the app I get a 'user denied request' page directly. Or other weird stuff happens(like half log-in page, half my app page). </p> <p>For the first request I am doing as below (I display data to show what I get back)</p> <pre><code>@csrf_exempt def frontpage(request): url = 'https://graph.facebook.com/oauth/authorize?client_id=myid&amp;redirect_uri=myurl' data = urllib2.urlopen(url) return render_to_response('myapp/frontpage.html', {"s": data}) </code></pre> <p>(It also confuses me that this page frontpage.html is rendered at all. Shouldn't it instead be rendering the response of the redirect url?)</p> <p>Anyone?</p> <p>EDIT:</p> <p>I now found a pyfacebook example, but it causes an infinite loop after logging in, continually getting new auth_token:</p> <pre><code>@csrf_exempt @facebook.require_login() def canvas(request): values = request.facebook.users.getInfo([request.facebook.uid], ['first_name', 'is_app_user', 'has_added_app'])[0] name, is_app_user, has_added_app = values['first_name'], values['is_app_user'], values['has_added_app'] if has_added_app == '0': return request.facebook.redirect(request.facebook.get_add_url()) return render_to_response('tube/canvas.fbml', {'name': name}) </code></pre> <p>I have not changed the example, except to add <code>@csrf_exempt</code>. I tried adding a parameter: <code>@facebook.require_login(next=1)</code>, which stops the loop. However, this request does not contain the facebook info. I saw this <a href="http://stackoverflow.com/questions/2349368/looping-redirect-with-pyfacebook-and-google-app-engine">Looping Redirect with PyFacebook and Google App Engine</a> Has that worked for anyone? What is the file that I am supposed to update?</p>