Exemplo n.º 1
0
    def _get_authorization(self):

        signature_method_hmac_sha1 = oauth.SignatureMethod_HMAC_SHA1(
        )  # @UnusedVariable
        oauth_consumer = oauth.Consumer(key=self.consumer_key,
                                        secret=self.consumer_secret)
        oauth_client = oauth.Client(oauth_consumer)

        logger.info('Requesting temp token from Twitter')

        resp, content = oauth_client.request(self.REQUEST_TOKEN_URL, 'GET')

        if resp['status'] != '200':
            logger.info(
                'Invalid respond from Twitter requesting temp token: %s' %
                resp['status'])
        else:
            request_token = dict(parse_qsl(content))

            lazylibrarian.TWITTER_USERNAME = request_token['oauth_token']
            lazylibrarian.TWITTER_PASSWORD = request_token[
                'oauth_token_secret']

            return self.AUTHORIZATION_URL + "?oauth_token=" + request_token[
                'oauth_token']
Exemplo n.º 2
0
    def get_credentials(self, key):
        request_token = dict(oauth_token=sickbeard.TWITTER_USERNAME, oauth_token_secret=sickbeard.TWITTER_PASSWORD,
                             oauth_callback_confirmed='true')

        token = oauth.Token(request_token['oauth_token'], request_token['oauth_token_secret'])
        token.set_verifier(key)

        self._log_debug('Generating and signing request for an access token using key ' + key)

        # noinspection PyUnusedLocal
        signature_method_hmac_sha1 = oauth.SignatureMethod_HMAC_SHA1()
        oauth_consumer = oauth.Consumer(key=self.consumer_key, secret=self.consumer_secret)
        self._log_debug('oauth_consumer: ' + str(oauth_consumer))
        oauth_client = oauth.Client(oauth_consumer, token)
        self._log_debug('oauth_client: ' + str(oauth_client))
        resp, content = oauth_client.request(self.ACCESS_TOKEN_URL, method='POST', body='oauth_verifier=%s' % key)
        self._log_debug('resp, content: ' + str(resp) + ',' + str(content))

        access_token = dict(parse_qsl(content))
        self._log_debug('access_token: ' + str(access_token))

        self._log_debug('resp[status] = ' + str(resp['status']))
        if '200' != resp['status']:
            self._log_error('The request for a token with did not succeed: ' + str(resp['status']))
            result = False
        else:
            self._log_debug('Your Twitter Access Token key: %s' % access_token['oauth_token'])
            self._log_debug('Access Token secret: %s' % access_token['oauth_token_secret'])
            sickbeard.TWITTER_USERNAME = access_token['oauth_token']
            sickbeard.TWITTER_PASSWORD = access_token['oauth_token_secret']
            result = True

        message = ('Key verification successful', 'Unable to verify key')[not result]
        logger.log(u'%s result: %s' % (self.name, message))
        return self._choose(message, result)
Exemplo n.º 3
0
    def _get_authorization(self):
        _ = oauth.SignatureMethod_HMAC_SHA1()
        oauth_consumer = oauth.Consumer(key=self.consumer_key,
                                        secret=self.consumer_secret)
        oauth_client = oauth.Client(oauth_consumer)

        logger.debug('Requesting temp token from Twitter')

        resp, content = oauth_client.request(self.REQUEST_TOKEN_URL, 'GET')

        if resp['status'] != '200':
            logger.error(
                'Invalid respond from Twitter requesting temp token: %s' %
                resp['status'])
        else:
            # noinspection PyDeprecation
            request_token = dict(parse_qsl(content))
            lazylibrarian.CONFIG['TWITTER_USERNAME'] = request_token[
                'oauth_token']
            lazylibrarian.CONFIG['TWITTER_PASSWORD'] = request_token[
                'oauth_token_secret']
            logger.debug('Twitter oauth_token = %s oauth_secret = %s' %
                         (lazylibrarian.CONFIG['TWITTER_USERNAME'],
                          lazylibrarian.CONFIG['TWITTER_PASSWORD']))
            return self.AUTHORIZATION_URL + "?oauth_token=" + request_token[
                'oauth_token']
Exemplo n.º 4
0
    def _get_credentials(self, key):
        request_token = {'oauth_token': lazylibrarian.CONFIG['TWITTER_USERNAME'],
                         'oauth_token_secret': lazylibrarian.CONFIG['TWITTER_PASSWORD'],
                         'oauth_callback_confirmed': 'true'}

        token = oauth.Token(request_token['oauth_token'], request_token['oauth_token_secret'])
        token.set_verifier(key)

        logger.info('Generating and signing request for an access token using key ' + key)

        _ = oauth.SignatureMethod_HMAC_SHA1()
        oauth_consumer = oauth.Consumer(key=self.consumer_key, secret=self.consumer_secret)
        logger.info('oauth_consumer: ' + str(oauth_consumer))
        oauth_client = oauth.Client(oauth_consumer, token)
        logger.info('oauth_client: ' + str(oauth_client))
        resp, content = oauth_client.request(self.ACCESS_TOKEN_URL, method='POST', body='oauth_verifier=%s' % key)
        logger.info('resp, content: ' + str(resp) + ',' + str(content))

        access_token = dict(parse_qsl(content))
        logger.info('access_token: ' + str(access_token))

        logger.info('resp[status] = ' + str(resp['status']))
        if resp['status'] != '200':
            logger.error('The request for a token with did not succeed: ' + str(resp['status']))
            return False
        else:
            logger.info('Your Twitter Access Token key: %s' % access_token['oauth_token'])
            logger.info('Access Token secret: %s' % access_token['oauth_token_secret'])
            lazylibrarian.CONFIG['TWITTER_USERNAME'] = access_token['oauth_token']
            lazylibrarian.CONFIG['TWITTER_PASSWORD'] = access_token['oauth_token_secret']
            return True
Exemplo n.º 5
0
 def _get_credentials(self, key):
     request_token = {}
 
     request_token['oauth_token'] = sickbeard.TWITTER_USERNAME
     request_token['oauth_token_secret'] = sickbeard.TWITTER_PASSWORD
     request_token['oauth_callback_confirmed'] = 'true'
 
     token = oauth.Token(request_token['oauth_token'], request_token['oauth_token_secret'])
     token.set_verifier(key)
 
     logger.log('Generating and signing request for an access token using key '+key)
 
     signature_method_hmac_sha1 = oauth.SignatureMethod_HMAC_SHA1() #@UnusedVariable
     oauth_consumer             = oauth.Consumer(key=self.consumer_key, secret=self.consumer_secret)
     logger.log('oauth_consumer: '+str(oauth_consumer))
     oauth_client  = oauth.Client(oauth_consumer, token)
     logger.log('oauth_client: '+str(oauth_client))
     resp, content = oauth_client.request(self.ACCESS_TOKEN_URL, method='POST', body='oauth_verifier=%s' % key)
     logger.log('resp, content: '+str(resp)+','+str(content))
 
     access_token  = dict(parse_qsl(content))
     logger.log('access_token: '+str(access_token))
 
     logger.log('resp[status] = '+str(resp['status']))
     if resp['status'] != '200':
         logger.log('The request for a token with did not succeed: '+str(resp['status']), logger.ERROR)
         return False
     else:
         logger.log('Your Twitter Access Token key: %s' % access_token['oauth_token'])
         logger.log('Access Token secret: %s' % access_token['oauth_token_secret'])
         sickbeard.TWITTER_USERNAME = access_token['oauth_token']
         sickbeard.TWITTER_PASSWORD = access_token['oauth_token_secret']
         return True
Exemplo n.º 6
0
    def __init__(self, consumer_key, consumer_secret, server_url, request_token_url, access_token_url, authorization_url):
        self.consumer_secret = consumer_secret
        self.consumer_key = consumer_key

        self.consumer = oauth2.Consumer(consumer_key, consumer_secret)
        self.signature_method = oauth2.SignatureMethod_HMAC_SHA1()

        self.server_url = server_url
        self.request_token_url = request_token_url
        self.access_token_url = access_token_url
        self.authorization_url = authorization_url
Exemplo n.º 7
0
    def get_authorization(self):

        # noinspection PyUnusedLocal
        signature_method_hmac_sha1 = oauth.SignatureMethod_HMAC_SHA1()
        oauth_consumer = oauth.Consumer(key=self.consumer_key, secret=self.consumer_secret)
        oauth_client = oauth.Client(oauth_consumer)

        self._log_debug('Requesting temp token from Twitter')

        resp, content = oauth_client.request(self.REQUEST_TOKEN_URL, 'GET')

        if '200' != resp['status']:
            self._log_error('Invalid response from Twitter requesting temp token: %s' % resp['status'])
        else:
            request_token = dict(parse_qsl(content))

            sickbeard.TWITTER_USERNAME = request_token['oauth_token']
            sickbeard.TWITTER_PASSWORD = request_token['oauth_token_secret']

            return self.AUTHORIZATION_URL + '?oauth_token=' + request_token['oauth_token']