X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/a9eef437702d5df7a2f97010e6798c689371808c..174c53e97bcf1e5412c141829d152aa5a2b8684c:/forum_modules/oauthauth/authentication.py diff --git a/forum_modules/oauthauth/authentication.py b/forum_modules/oauthauth/authentication.py old mode 100755 new mode 100644 index cfe8156..93cdc59 --- a/forum_modules/oauthauth/authentication.py +++ b/forum_modules/oauthauth/authentication.py @@ -1,41 +1,41 @@ -from consumer import OAuthAbstractAuthConsumer -from forum.authentication.base import ConsumerTemplateContext - -try: - import json as simplejson -except ImportError: - from django.utils import simplejson - -from lib import oauth -import settings - -class TwitterAuthConsumer(OAuthAbstractAuthConsumer): - def __init__(self): - OAuthAbstractAuthConsumer.__init__(self, - settings.TWITTER_CONSUMER_KEY, - settings.TWITTER_CONSUMER_SECRET, - "twitter.com", - "https://twitter.com/oauth/request_token", - "https://twitter.com/oauth/access_token", - "https://twitter.com/oauth/authorize", - ) - - def get_user_data(self, key): - json = self.fetch_data(key, "https://twitter.com/account/verify_credentials.json") - - if 'screen_name' in json: - creds = simplejson.loads(json) - - return { - 'username': creds['screen_name'] - } - - - return {} - -class TwitterAuthContext(ConsumerTemplateContext): - mode = 'BIGICON' - type = 'DIRECT' - weight = 150 - human_name = 'Twitter' +from consumer import OAuthAbstractAuthConsumer +from forum.authentication.base import ConsumerTemplateContext + +try: + import json as simplejson +except ImportError: + from django.utils import simplejson + +from lib import oauth +import settings + +class TwitterAuthConsumer(OAuthAbstractAuthConsumer): + def __init__(self): + OAuthAbstractAuthConsumer.__init__(self, + str(settings.TWITTER_CONSUMER_KEY), + str(settings.TWITTER_CONSUMER_SECRET), + "twitter.com", + "https://twitter.com/oauth/request_token", + "https://twitter.com/oauth/access_token", + "https://twitter.com/oauth/authorize", + ) + + def get_user_data(self, key): + json = self.fetch_data(key, "https://twitter.com/account/verify_credentials.json") + + if 'screen_name' in json: + creds = simplejson.loads(json) + + return { + 'username': creds['screen_name'] + } + + + return {} + +class TwitterAuthContext(ConsumerTemplateContext): + mode = 'BIGICON' + type = 'DIRECT' + weight = 150 + human_name = 'Twitter' icon = '/media/images/openid/twitter.png' \ No newline at end of file