Exemplo n.º 1
0
 def call_api(self, method=None, params={}, type='blog', verb='get'):
     """A simple abstraction for calling the tumblr api"""
     if method:
         endpoint = ('http://api.tumblr.com/v2/blog/%s%s'
             % (self.base_hostname, method))
         if verb == 'post':
             req = requests.post(url=endpoint, data=params, auth=self.oauth)
         else:
             req = requests.get(url=endpoint, params=params, auth=self.oauth)
         return req.json()
     return None
Exemplo n.º 2
0
 def call_api(self, method=None, params={}, type='blog', verb='get'):
     """A simple abstraction for calling the tumblr api"""
     if method:
         endpoint = ('https://api.tumblr.com/v2/blog/%s%s' %
                     (self.base_hostname, method))
         if verb == 'post':
             req = requests.post(url=endpoint, data=params, auth=self.oauth)
         else:
             req = requests.get(url=endpoint,
                                params=params,
                                auth=self.oauth)
         return req.json()
     return None
Exemplo n.º 3
0
    def get_tokens(self):
        oauth = OAuth1(self.consumer_key,
            client_secret=self.secret_key,
            resource_owner_key=self.oauth_token,
            resource_owner_secret=self.oauth_token_secret,
            verifier=self.oauth_verifier)
        req = requests.post(url=self.access_token_url, auth=oauth)
        logging.info("access token content: %s" % req.text)
        creds = parse_qs(req.text)

        logging.info("getting long-lasting access tokens")
        self.oauth_token = creds.get('oauth_token')[0]
        logging.info('oauth_token: %s' % self.oauth_token)
        self.oauth_token_secret = creds.get('oauth_token_secret')[0]
        logging.info('oauth_token_secret: %s' % self.oauth_token_secret)
Exemplo n.º 4
0
    def get_tokens(self):
        oauth = OAuth1(self.consumer_key,
                       client_secret=self.secret_key,
                       resource_owner_key=self.oauth_token,
                       resource_owner_secret=self.oauth_token_secret,
                       verifier=self.oauth_verifier)
        req = requests.post(url=self.access_token_url, auth=oauth)
        logging.info("access token content: %s" % req.text)
        creds = parse_qs(req.text)

        logging.info("getting long-lasting access tokens")
        self.oauth_token = creds.get('oauth_token')[0]
        logging.info('oauth_token: %s' % self.oauth_token)
        self.oauth_token_secret = creds.get('oauth_token_secret')[0]
        logging.info('oauth_token_secret: %s' % self.oauth_token_secret)
Exemplo n.º 5
0
    def start_auth(self):
        oauth = OAuth1(self.consumer_key,
            client_secret=self.secret_key)
        # TODO move this callback url into some more abstracted settings
        payload = {'oauth_callback':'http://0.0.0.0:8123/stumblrcallback'}
        req = requests.post(url=self.request_token_url, params=payload,
            auth=oauth)
        logging.info('request token content: %s' % req.text)
        creds = parse_qs(req.text)

        logging.info(creds)
        # gather some parsed tokens from the request
        self.oauth_token = creds.get('oauth_token')[0]
        logging.info('oauth_token: %s' % self.oauth_token)
        self.oauth_token_secret = creds.get('oauth_token_secret')[0]
        logging.info('oauth_token_secret: %s' % self.oauth_token_secret)
        return True
Exemplo n.º 6
0
    def start_auth(self):
        oauth = OAuth1(self.consumer_key, client_secret=self.secret_key)
        # TODO move this callback url into some more abstracted settings
        payload = {'oauth_callback': 'http://0.0.0.0:8123/stumblrcallback'}
        req = requests.post(url=self.request_token_url,
                            params=payload,
                            auth=oauth)
        logging.info('request token content: %s' % req.text)
        creds = parse_qs(req.text)

        logging.info(creds)
        # gather some parsed tokens from the request
        self.oauth_token = creds.get('oauth_token')[0]
        logging.info('oauth_token: %s' % self.oauth_token)
        self.oauth_token_secret = creds.get('oauth_token_secret')[0]
        logging.info('oauth_token_secret: %s' % self.oauth_token_secret)
        return True