Example #1
0
    def notify(self, message='', data={}):

        if self.isDisabled():
            return False

        try:
            data = urllib.urlencode({
                'msg': toUnicode(message),
            })

            req = urllib2.Request(self.url)
            authHeader = "Basic %s" % base64.encodestring(
                '%s:%s' % (self.conf('username'), self.conf('api_key')))[:-1]
            req.add_header("Authorization", authHeader)

            handle = urllib2.urlopen(req, data)
            result = json.load(handle)

            if result['status'] != 'success' or result[
                    'response_message'] != 'OK':
                raise Exception

        except Exception, e:
            log.error('Notification failed: %s' % e)
            return False
 def __init__(self):
     super(GoogleSignIn, self).__init__('google')
     googleinfo = urllib2.urlopen('https://accounts.google.com/.well-known/openid-configuration')
     google_params = json.load(googleinfo)
     self.service = OAuth2Service(
         name='google',
         client_id=self.consumer_id,
         client_secret=self.consumer_secret,
         authorize_url=google_params.get('authorization_endpoint'),
         base_url=google_params.get('userinfo_endpoint'),
         access_token_url=google_params.get('token_endpoint')
     )
Example #3
0
    def notify(self, message = '', data = {}):
        if self.isDisabled(): return

        try:
            params = {
                'msg': toUnicode(message),
            }

            headers = {
                'Authorization': "Basic %s" % base64.encodestring('%s:%s' % (self.conf('username'), self.conf('api_key')))[:-1]
            }

            handle = self.urlopen(self.url, params = params, headers = headers)
            result = json.load(handle)

            if result['status'] != 'success' or result['response_message'] != 'OK':
                raise Exception

        except Exception, e:
            log.error('Notification failed: %s' % e)
            return False
Example #4
0
    def notify(self, message = '', data = {}):

        if self.isDisabled():
            return False

        try:
            data = urllib.urlencode({
                'msg': toUnicode(message),
            })

            req = urllib2.Request(self.url)
            authHeader = "Basic %s" % base64.encodestring('%s:%s' % (self.conf('username'), self.conf('api_key')))[:-1]
            req.add_header("Authorization", authHeader)

            handle = urllib2.urlopen(req, data)
            result = json.load(handle)

            if result['status'] != 'success' or result['response_message'] != 'OK':
                raise Exception

        except Exception, e:
            log.error('Notification failed: %s' % e)
            return False
Example #5
0
 def get_user_info(self, resp):
     session['oauth_token'] = (resp['access_token'], '')
     url = self.auth_service.base_url + "?access_token=" + resp['access_token']
     userinfo = json.load(urllib2.urlopen(url))
     return userinfo['email']