1 from consumer import OAuthAbstractAuthConsumer
2 from forum.authentication.base import ConsumerTemplateContext
5 import json as simplejson
7 from django.utils import simplejson
12 class TwitterAuthConsumer(OAuthAbstractAuthConsumer):
14 OAuthAbstractAuthConsumer.__init__(self,
15 str(settings.TWITTER_CONSUMER_KEY),
16 str(settings.TWITTER_CONSUMER_SECRET),
18 "https://api.twitter.com/oauth/request_token",
19 "https://api.twitter.com/oauth/access_token",
20 "https://api.twitter.com/oauth/authorize",
23 def get_user_data(self, key):
24 json = self.fetch_data(key, "https://twitter.com/account/verify_credentials.json")
26 if 'screen_name' in json:
27 creds = simplejson.loads(json)
30 'username': creds['screen_name']
36 class TwitterAuthContext(ConsumerTemplateContext):
40 human_name = 'Twitter'
41 icon = '/media/images/openid/twitter.png'