url: facebook: pattern: /facebook/(.*) handler: FacebookGraphHandler kwargs: # Visit https://developers.facebook.com/apps/ to get these keys key: '...' secret: '...' redirect: header: Referer url: /$YAMLURL/
Follow the steps for Facebook auth to get the keys above.
Now, follow these steps:
The request below will show your name once you log in. To log in, visit /facebook/:
$.get('facebook/me') // OUTPUT
After the OAuth login, users can be redirected via the
documented the redirection configuration.
The FacebookGraphHandler is very similar to the TwitterRESTHandler in many ways:
path:configuration to hard-code a specific request. See the Twitter paths
transform:configuration to modify the response in any way. See the Twitter transforms documentation.
POST, you can use the
GETmethod as well. See the documentation on Twitter GET requests
If your app needs to persist the user’s access token, add
to the kwargs. The first time, the user is asked to log in. Thereafter, the
user’s credentials are available for all future requests.
This is typically used to show the latest posts / photos of a user or page on every visit. Typically, such requests are cached as well. Here is a sample configuration:
url: facebook-persist: pattern: /persist/(.*) handler: FacebookGraphHandler kwargs: key: '...' secret: '...' access_token: persist # Persist the access token after first login cache: duration: 300 # Cache requests for 5 seconds
Here is a sample response:
$.get('persist/me') // OUTPUT
The first time, you get an access_token error. Visit /persist/ to log in. Thereafter, your access_token will be stored and used for future requests until it expires, or a user logs in again at /persist/.