当前位置: 首页>>代码示例>>Python>>正文


Python OAuthRequest.from_consumer_and_token方法代码示例

本文整理汇总了Python中oauth.OAuthRequest.from_consumer_and_token方法的典型用法代码示例。如果您正苦于以下问题:Python OAuthRequest.from_consumer_and_token方法的具体用法?Python OAuthRequest.from_consumer_and_token怎么用?Python OAuthRequest.from_consumer_and_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oauth.OAuthRequest的用法示例。


在下文中一共展示了OAuthRequest.from_consumer_and_token方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load

# 需要导入模块: from oauth import OAuthRequest [as 别名]
# 或者: from oauth.OAuthRequest import from_consumer_and_token [as 别名]
 def load(self, url, method="GET", parameters=None, raw=False):
     oauth_request = OAuthRequest.from_consumer_and_token(self.consumer,
             token=self.access_token, http_url=url, http_method=method,
             parameters=parameters)
     oauth_request.sign_request(self.signature_method, self.consumer,
             self.access_token)
     return self.oauth_fetch(oauth_request, raw)
开发者ID:afternoon,项目名称:followize,代码行数:9,代码来源:twitter.py

示例2: execute

# 需要导入模块: from oauth import OAuthRequest [as 别名]
# 或者: from oauth.OAuthRequest import from_consumer_and_token [as 别名]
    def execute(self, url, params, consumer, access_token, method='POST', mode='header'):
        headers = {}
        headers.setdefault('User-Agent', "python")
        headers.setdefault("Accept", "text/html")
        headers.setdefault("Content-Type", "application/x-www-form-urlencoded")

        request = OAuthRequest.from_consumer_and_token(
            self.consumer,
            http_url=url,
            http_method=method,
            token=access_token,
            parameters=params,
        )
        request.sign_request(OAuthSignatureMethod_HMAC_SHA1(), consumer, access_token)
        if mode == 'header':
            headers.update(request.to_header())
        else:
            url = request.get_normalized_http_url()
            params = request.to_postdata()
        multipart_encode({})
        host, path = _url_spllit(url)
        conn = httplib.HTTPConnection(host)

        conn.request(method, path, params, headers)
        resp = conn.getresponse()
        json = resp.read()
        conn.close()
        return json
开发者ID:wayly,项目名称:cnapi,代码行数:30,代码来源:api.py

示例3: build

# 需要导入模块: from oauth import OAuthRequest [as 别名]
# 或者: from oauth.OAuthRequest import from_consumer_and_token [as 别名]
def build(http_url, token, http_method='GET'):

    # build and return oauth request url
    
    match = re.match('(.+):(.+)@(.+)', token)
        
    try:
        token = oauth.OAuthToken(
            match.group(1),
            match.group(2)
        )
    except Exception:
        raise InvalidAccessToken('the provided access token is invalid.')
    
    url = BASE_API_URI + http_url

    if not consumer_key:
        raise MissingKeyError('provide consumer key')
    if not consumer_secret:
        raise MissingKeyError('provide consumer consumer_secret')
    oauth_consumer = oauth.OAuthConsumer(consumer_key, consumer_secret)

    request = OAuthRequest.from_consumer_and_token(
        oauth_consumer,
        http_url=url,
        token=token,
        http_method=http_method,
        parameters={}
    )
    
    request.sign_request(SIGNATURE_METHOD, oauth_consumer, token)

    return request.to_url()
开发者ID:kelonye,项目名称:python-twitter,代码行数:35,代码来源:__init__.py

示例4: createOauthRequest

# 需要导入模块: from oauth import OAuthRequest [as 别名]
# 或者: from oauth.OAuthRequest import from_consumer_and_token [as 别名]
def createOauthRequest(http_url, params, default_params):

    validateOptions(params, default_params)

    default_params.update(params)
    params = default_params

    http_method = "GET"
    token = params.pop("token", None)

    base_url = "https://www.pesapal.com/api/"
    if testing:
        base_url = "https://demo.pesapal.com/api/"

    url = base_url + http_url

    if not consumer_key:
        raise MissingKeyError("provide consumer key")
    if not consumer_secret:
        raise MissingKeyError("provide consumer consumer_secret")
    oauth_consumer = oauth.OAuthConsumer(consumer_key, consumer_secret)

    request = OAuthRequest.from_consumer_and_token(
        oauth_consumer, http_url=url, http_method=http_method, parameters=params
    )
    request.sign_request(SIGNATURE_METHOD, oauth_consumer, token)
    return request.to_url()
开发者ID:kelonye,项目名称:gae-pesapal,代码行数:29,代码来源:__init__.py

示例5: access_resource

# 需要导入模块: from oauth import OAuthRequest [as 别名]
# 或者: from oauth.OAuthRequest import from_consumer_and_token [as 别名]
    def access_resource(self,
                        relative_url,
                        access_token,
                        method="GET",
                        params=None):

        full_url = self.server_url + relative_url
        url = urlparse.urlparse(full_url)
        full_params = cgi.parse_qs(url.query)
        for key in full_params:
            full_params[key] = full_params[key][0]

        if params:
            full_params.update(params)

        oauth_request = OAuthRequest.from_consumer_and_token(
                self.consumer,
                token = access_token,
                http_url = full_url,
                parameters = full_params,
                http_method=method
                )

        oauth_request.sign_request(OAuthSignatureMethod_HMAC_SHA1(), self.consumer, access_token)

        if method == "GET":
            response = get_response(oauth_request.to_url())
        else:
            response = post_response(full_url, oauth_request.to_postdata())

        return response
开发者ID:DannyBenItzhak,项目名称:analytics,代码行数:33,代码来源:test_oauth_client.py

示例6: start_fetch_request_token

# 需要导入模块: from oauth import OAuthRequest [as 别名]
# 或者: from oauth.OAuthRequest import from_consumer_and_token [as 别名]
    def start_fetch_request_token(self):
        oauth_request = OAuthRequest.from_consumer_and_token(
            self.consumer, http_url="%s/api/auth/request_token" % self.server_url
        )

        oauth_request.sign_request(OAuthSignatureMethod_HMAC_SHA1(), self.consumer, None)
        webbrowser.open(oauth_request.to_url())
开发者ID:mwahl,项目名称:analytics,代码行数:9,代码来源:test_oauth_client.py

示例7: build_oauth_request

# 需要导入模块: from oauth import OAuthRequest [as 别名]
# 或者: from oauth.OAuthRequest import from_consumer_and_token [as 别名]
 def build_oauth_request(self, http_url, token=None,
                         http_method="GET", parameters=None):
     oauth_request = OAuthRequest.from_consumer_and_token(
         self.consumer, token=token, http_method=http_method,
         http_url=http_url, parameters=parameters
     )
     oauth_request.sign_request(self.signature_method, self.consumer, token)
     return oauth_request
开发者ID:sunsuk7tp,项目名称:oauthlib,代码行数:10,代码来源:oauth_tools.py

示例8: exchange_request_token_for_access_token

# 需要导入模块: from oauth import OAuthRequest [as 别名]
# 或者: from oauth.OAuthRequest import from_consumer_and_token [as 别名]
 def exchange_request_token_for_access_token(self, token):
     oauth_request = OAuthRequest.from_consumer_and_token(self.consumer,
             token=token, http_url=URL_OAUTH_ACCESS_TOKEN)
     oauth_request.sign_request(self.signature_method, self.consumer,
             token)
     resp = self.oauth_fetch(oauth_request, raw=True)
     self.access_token = OAuthToken.from_string(resp) 
     return self.access_token
开发者ID:afternoon,项目名称:followize,代码行数:10,代码来源:twitter.py

示例9: login

# 需要导入模块: from oauth import OAuthRequest [as 别名]
# 或者: from oauth.OAuthRequest import from_consumer_and_token [as 别名]
def login():
    oauth_request = OAuthRequest.from_consumer_and_token(
                        consumer,
                        callback='http://127.0.0.1:5000/oauth_callback',
                        http_url='http://www.khanacademy.org/api/auth/request_token'
                    )
    oauth_request.sign_request(OAuthSignatureMethod_HMAC_SHA1(), consumer, None)
    return redirect(oauth_request.to_url())
开发者ID:xmarcosx,项目名称:khan-academy-dashboard,代码行数:10,代码来源:views.py

示例10: start_fetch_request_token

# 需要导入模块: from oauth import OAuthRequest [as 别名]
# 或者: from oauth.OAuthRequest import from_consumer_and_token [as 别名]
    def start_fetch_request_token(self, callback=None):
        oauth_request = OAuthRequest.from_consumer_and_token(
                self.consumer,
                callback=callback,
                http_url="%s/api/auth/request_token" % self.server_url
                )

        oauth_request.sign_request(OAuthSignatureMethod_HMAC_SHA1(), self.consumer, None)
        return oauth_request.to_url()
开发者ID:Aypak,项目名称:ka-lite,代码行数:11,代码来源:test_oauth_client.py

示例11: get

# 需要导入模块: from oauth import OAuthRequest [as 别名]
# 或者: from oauth.OAuthRequest import from_consumer_and_token [as 别名]
 def get(self, path, token=None, prefix="/api"):
     url = "http://%s%s%s" % (self.host, prefix, path)
     request = OAuthRequest.from_consumer_and_token(
         self.consumer,
         token,
         http_method='GET',
         http_url=url
     )
     return self._send_request(request, token)
开发者ID:spulec,项目名称:buriedtv,代码行数:11,代码来源:JtvClient.py

示例12: start_fetch_request_token

# 需要导入模块: from oauth import OAuthRequest [as 别名]
# 或者: from oauth.OAuthRequest import from_consumer_and_token [as 别名]
    def start_fetch_request_token(self, callback=None):
        oauth_request = OAuthRequest.from_consumer_and_token(
                self.consumer,
                callback=callback,
                http_url="%s/api/auth/request_token" % self.server_url
                )

        oauth_request.sign_request(OAuthSignatureMethod_HMAC_SHA1(), self.consumer, None)
        print 'opening webbrowser with', oauth_request.to_url()
        webbrowser.open(oauth_request.to_url())
开发者ID:GenerationKnown,项目名称:EurlPythonServer,代码行数:12,代码来源:test_oauth_client.py

示例13: post

# 需要导入模块: from oauth import OAuthRequest [as 别名]
# 或者: from oauth.OAuthRequest import from_consumer_and_token [as 别名]
 def post(self, path, post_params, token=None, prefix="/api"):
     url = "http://%s%s%s" % (self.host, prefix, path)
     request = OAuthRequest.from_consumer_and_token(
         self.consumer,
         token,
         http_method='POST',
         http_url=url,
         parameters=post_params
     )
     return self._send_request(request, token)
开发者ID:spulec,项目名称:buriedtv,代码行数:12,代码来源:JtvClient.py

示例14: fetch_access_token

# 需要导入模块: from oauth import OAuthRequest [as 别名]
# 或者: from oauth.OAuthRequest import from_consumer_and_token [as 别名]
    def fetch_access_token(self, request_token):

        oauth_request = OAuthRequest.from_consumer_and_token(
            self.consumer, token=request_token, http_url="%s/api/auth/access_token" % self.server_url
        )

        oauth_request.sign_request(OAuthSignatureMethod_HMAC_SHA1(), self.consumer, request_token)

        response = get_response(oauth_request.to_url())

        return OAuthToken.from_string(response)
开发者ID:mwahl,项目名称:analytics,代码行数:13,代码来源:test_oauth_client.py

示例15: _get_authorize_request

# 需要导入模块: from oauth import OAuthRequest [as 别名]
# 或者: from oauth.OAuthRequest import from_consumer_and_token [as 别名]
 def _get_authorize_request(self):
     params = {}
     if self.desktop:
         url = self._url_autorize
         params['oauth_callback'] = 'oob'
     else:
         url = self._url_authenticate
     if self.force_login:
             params['force_login'] = 'true'
     return OAuthRequest.from_consumer_and_token(self.consumer, 
                                                 token=self.token, 
                                                 http_url=url, 
                                                 parameters=params)
开发者ID:carlitux,项目名称:mtweets,代码行数:15,代码来源:utils.py


注:本文中的oauth.OAuthRequest.from_consumer_and_token方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。