Exemplo n.º 1
0
 def oauth_authorization_request(self, token):
     """Generate OAuth request to authorize token."""
     params = self.auth_extra_arguments() or {}
     params.update(self.get_scope_argument())
     return OAuthRequest.from_token_and_callback(
         token=token, callback=self.redirect_uri, http_url=self.AUTHORIZATION_URL, parameters=params
     )
Exemplo n.º 2
0
 def oauth_authorization_request(self, token):
     """Generate OAuth request to authorize token."""
     return OAuthRequest.from_token_and_callback(
         token=token,
         callback=self.redirect_uri,
         http_url=self.AUTHORIZATION_URL,
         parameters=self.auth_extra_arguments())
Exemplo n.º 3
0
 def oauth_authorization_request_(self, token):
     """Generate OAuth request to authorize token."""
     
     request =  OAuthRequest.from_token_and_callback(
         token=token,
         http_url=self.AUTHORIZATION_URL,
     )
     request.is_form_encoded = True
     consumer = OAuthConsumer(*self.get_key_and_secret())
     request.sign_request(SignatureMethod_HMAC_SHA1(), consumer, token)
     return request
Exemplo n.º 4
0
Arquivo: api.py Projeto: mogi/sandbox
 def get_auth_url(self, callback_url):
     # get request token
     oauth_request = Request.from_consumer_and_token(
         self.consumer, http_method="POST",
         http_url=self.request_token_url,
         parameters={'oauth_callback': callback_url})
     oauth_request.sign_request(SignatureMethod_HMAC_SHA1(),
                                self.consumer, None)
     token = self.fetch_request_token(oauth_request)
     # get authorization url
     oauth_request = Request.from_token_and_callback(
                         token=token, http_url=self.authorization_url)
     return oauth_request.to_url(), token
Exemplo n.º 5
0
 def oauth_authorization_request(self, token):
     """Generate OAuth request to authorize token."""
     params = self.auth_extra_arguments() or {}
     params.update(self.get_scope_argument())
     params.update({"oauth_nonce":OAuthRequest.make_nonce()})
     params.update({"oauth_timestamp":OAuthRequest.make_timestamp()})
     params.update({"method": "profile.get_auth"})
     
     request =  OAuthRequest.from_token_and_callback(
         token=token,
         callback=self.redirect_uri,
         http_url=self.AUTHORIZATION_URL,
         parameters=params
     )
     request.is_form_encoded = True
     consumer = OAuthConsumer(*self.get_key_and_secret())
     request.sign_request(SignatureMethod_HMAC_SHA1(), consumer, token)
     return request
Exemplo n.º 6
0
Arquivo: api.py Projeto: mogi/sandbox
def auth(callback_url):
    # setup
    client = SimpleClient(SERVER, REQUEST_TOKEN_URL, ACCESS_TOKEN_URL)
    consumer = Consumer(CONSUMER_KEY, CONSUMER_SECRET)

    # get request token
    oauth_request = Request.from_consumer_and_token(
        consumer, http_method="POST",
        http_url=client.request_token_url,
        parameters={'oauth_callback': callback_url})
    oauth_request.sign_request(SignatureMethod_HMAC_SHA1(),
                               consumer, None)
    token = client.fetch_request_token(oauth_request)
    cache.set('app.root.view.post::oauth_token', token.key, 300)
    cache.set('app.root.view.post::oauth_token_secret', token.secret, 300)

    oauth_request = Request.from_token_and_callback(
                        token=token, http_url=AUTHORIZATION_URL)
    return oauth_request.to_url()
Exemplo n.º 7
0
def auth(callback_url):
    # setup
    client = SimpleClient(SERVER, REQUEST_TOKEN_URL, ACCESS_TOKEN_URL)
    consumer = Consumer(CONSUMER_KEY, CONSUMER_SECRET)

    # get request token
    oauth_request = Request.from_consumer_and_token(
        consumer,
        http_method="POST",
        http_url=client.request_token_url,
        parameters={'oauth_callback': callback_url})
    oauth_request.sign_request(SignatureMethod_HMAC_SHA1(), consumer, None)
    token = client.fetch_request_token(oauth_request)
    cache.set('app.root.view.post::oauth_token', token.key, 300)
    cache.set('app.root.view.post::oauth_token_secret', token.secret, 300)

    oauth_request = Request.from_token_and_callback(token=token,
                                                    http_url=AUTHORIZATION_URL)
    return oauth_request.to_url()
Exemplo n.º 8
0
 def authorization_redirect(self, token):
     """Get the authorization URL to redirect the user"""
     request = Request.from_token_and_callback(token=token, http_url=self.authorize_url)
     return request.to_url()
Exemplo n.º 9
0
 def get_authorization_url(cls, request_key, request_secret, callback=None):
     token = Token(request_key, request_secret)
     request = Request.from_token_and_callback(token=token, 
                                               http_url=AUTHORIZATION_URL, 
                                               callback=callback)
     return request.to_url()