{# index.html #} {% extends "base.html" %} {% block body %} Home {# Check for errors. #} {% if result.error %}

Damn that error: {{ result.error.message }}

{% endif %} {# Welcome the user. #} {% if result.user %}

Hi {{ result.user.name }}

Your id is: {{ result.user.id }}

Your email is: {{ result.user.email }}

{% endif %} {# If the user has credentials, we can access his/her protected resources. #} {% if result.user.credentials %} {# Let's get the user's 5 most recent statuses. #} {% if result.provider.name == 'fb' %} Your are logged in with Facebook.
{# Insert the user's ID to the URL and access the resource. #} {% set url = 'https://graph.facebook.com/{0}?fields=feed.limit(5)'.format(result.user.id) %} {% set response = result.provider.access(url) %} {# Parse the response. #} {% if response.status == 200 %} {% if response.data.error %} Damn that error: {{ response.data.error }}! {% endif %} {% if response.data.feed.data %} Your 5 most recent statuses:
{% for status in response.data.feed.data %}

{{ status.message or status.name or status.story }}

Posted on: {{ status.created_time }} {% endfor %} {% endif %} {% endif %}{# response.status == 200 #} {% endif %}{# result.provider.name == 'fb' #} {# Do the same for Twitter. #} {% if result.provider.name == 'tw' %} Your are logged in with Twitter.
{% set url = 'https://api.twitter.com/1.1/statuses/user_timeline.json?count=5' %} {% set response = result.provider.access(url) %} {% if response.status == 200 %} {% if response.data.errors %} Damn that error: {{ response.data.errors }}! {% endif %} {% if response.data %} Your 5 most recent tweets:
{% for tweet in response.data %}

{{ tweet.text }}

Posted on: {{ tweet.created_at }} {% endfor %} {% endif %} {% endif %} {% endif %}{# result.provider.name == 'tw' #} {% endif %}{# result.user.credentials #} {% endblock body %}