3 from consumer import OAuthAbstractAuthConsumer
4 from forum.authentication.base import ConsumerTemplateContext
9 class TwitterAuthConsumer(OAuthAbstractAuthConsumer):
11 OAuthAbstractAuthConsumer.__init__(self,
12 str(settings.TWITTER_CONSUMER_KEY),
13 str(settings.TWITTER_CONSUMER_SECRET),
15 "https://api.twitter.com/oauth/request_token",
16 "https://api.twitter.com/oauth/access_token",
17 "https://api.twitter.com/oauth/authorize",
20 def get_user_data(self, key):
21 json = self.fetch_data(key, "https://twitter.com/account/verify_credentials.json")
23 if 'screen_name' in json:
24 creds = json.loads(json)
27 'username': creds['screen_name']
33 class TwitterAuthContext(ConsumerTemplateContext):
37 human_name = 'Twitter'
38 icon = '/media/images/openid/twitter.png'