Ejemplo n.º 1
0
def authorize_phase(c):
    """ Perform authorization task
        :return: authorized url
    """
    url_root = container(c, c['authorize_path'])
    url_query = "?oauth_token=%s&oauth_consumer_key=%s" % (c['oauth_token'],
                                                           c['client_key'])
    url = url_root + url_query
    return url
Ejemplo n.º 2
0
def request_phase(c):
    """ Perform initial OAuth Request to get a token, secret
    """
    request_url = container(c, c['request_path'])
    oauth = OAuth1(c['client_key'], 
                   client_secret=c['client_secret'],
                   callback_uri=c['callback_uri'])

    r = requests.post(url=request_url, auth=oauth)
    credentials = parse_qs(r.content)
    c['oauth_token'] = credentials.get('oauth_token')[0]
    c['oauth_token_secret'] = credentials.get('oauth_token_secret')[0]
Ejemplo n.º 3
0
def access_phase(c, verifier):
    """ Access phase
    """
    access_url = container(c, c['access_path'])
    oauth = OAuth1(c['client_key'],
                   client_secret=c['client_secret'],
                   resource_owner_key=c['oauth_token'],
                   resource_owner_secret=c['oauth_token_secret'],
                   verifier=verifier)
    r = requests.post(url=access_url, auth=oauth)
    credentials = parse_qs(r.content)
    c['oauth_token'] = credentials.get('oauth_token')[0]
    c['oauth_token_secret'] = credentials.get('oauth_token_secret')[0]
Ejemplo n.º 4
0
 def test_common_sandbox(self):
     self.c['sandbox'] = True
     self.assertTrue("test.salesforce.com" in container(self.c, '/'))
Ejemplo n.º 5
0
 def test_common_production(self):
     self.c['sandbox'] = False
     self.assertTrue("login.salesforce.com" in container(self.c, '/'))