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


Python OAuthRequest.from_token_and_callback方法代码示例

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


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

示例1: _makeURL

# 需要导入模块: from oauth.oauth import OAuthRequest [as 别名]
# 或者: from oauth.oauth.OAuthRequest import from_token_and_callback [as 别名]
 def _makeURL(result):
     token = OAuthToken.from_string(result)
     # Store the token by key so we can find it when the callback comes.
     oauthTokenDict[token.key] = token
     request = OAuthRequest.from_token_and_callback(
         token=token, http_url=conf.authorization_url)
     url = request.to_url()
     log.msg('Browser OAuth redirect URL = %r' % url)
     return url
开发者ID:ceronman,项目名称:lastpage-server,代码行数:11,代码来源:twitter.py

示例2: get_authorization_url

# 需要导入模块: from oauth.oauth import OAuthRequest [as 别名]
# 或者: from oauth.oauth.OAuthRequest import from_token_and_callback [as 别名]
    def get_authorization_url(self, token):
        """ Return URL from which a user can authorize Yammer API access for
        a given application.

        Keyword arguments:
        token -- an unauthorized OAuth request token

        """
        try:
            oauth_request = OAuthRequest.from_token_and_callback(
                                            token=token,
                                            http_url=YAMMER_AUTHORIZATION_URL)
            url = oauth_request.to_url()
        except OAuthError, m:
            raise YammerError(m.message)
开发者ID:jaivikram,项目名称:python-yammer-oauth,代码行数:17,代码来源:yammer.py

示例3: connect

# 需要导入模块: from oauth.oauth import OAuthRequest [as 别名]
# 或者: from oauth.oauth.OAuthRequest import from_token_and_callback [as 别名]
def connect(signal):    
    
    consumer = Token(CONSUMER_KEY,CONSUMER_SECRET)
    token = Token(ACCESS_KEY,ACCESS_SECRET)
        
    parameters = {
        'oauth_consumer_key': CONSUMER_KEY,
        'oauth_token': token.key,
        'oauth_signature_method': 'HMAC-SHA1',
        'oauth_timestamp': str(int(time.time())),
        'oauth_nonce': token._generate_nonce(),
        'oauth_version': '1.0',
    }
    
    access_token = token
    
    oauth_request = OAuthRequest.from_token_and_callback(access_token,
                    http_url=STREAM_URL, 
                    parameters=parameters)
    signature_method = OAuthSignatureMethod_HMAC_SHA1()
    signature = signature_method.build_signature(oauth_request, consumer, access_token)
    
    parameters['oauth_signature'] = signature
    
    data = urllib.urlencode(parameters)
    
    print "%s?%s" % (STREAM_URL,data)


    req = urllib2.urlopen("%s?%s" % (STREAM_URL,data))
    buffer = ''
    while True:
        
        chunk = req.read(1)
        if not chunk:
            print buffer
            break
        
        chunk = unicode(chunk)
        buffer += chunk
        
        tweets = buffer.split("\r\n",1)
        if len(tweets) > 1:
            #print tweets[0]
            signal.emit(tweets[0])
            buffer = tweets[1]
开发者ID:joshsharp,项目名称:enki,代码行数:48,代码来源:stream.py

示例4: Token

# 需要导入模块: from oauth.oauth import OAuthRequest [as 别名]
# 或者: from oauth.oauth.OAuthRequest import from_token_and_callback [as 别名]
access_token = Token(ACCESS_TOKEN,ACCESS_TOKEN_SECRET)
consumer = Token(CONSUMER_KEY,CONSUMER_SECRET)

parameters = {
    'oauth_consumer_key': CONSUMER_KEY,
    'oauth_token': access_token.key,
    'oauth_signature_method': 'HMAC-SHA1',
    'oauth_timestamp': str(int(time.time())),
    'oauth_nonce': access_token._generate_nonce(),
    'oauth_version': '1.0',
}


oauth_request = OAuthRequest.from_token_and_callback(access_token,
                http_url=STREAM_URL,
                parameters=parameters)
signature_method = OAuthSignatureMethod_HMAC_SHA1()
signature = signature_method.build_signature(oauth_request, consumer, access_token)

parameters['oauth_signature'] = signature

data = urllib.urlencode(parameters)

req = urllib2.urlopen("%s?%s" % (STREAM_URL,data))
buffer = ''


# We're using urllib2 to avoid external dependencies
# even though pyCurl actually handles the callbacks
# much more gracefully than this clumsy method.
开发者ID:akent,项目名称:tethered-swimming,代码行数:32,代码来源:stream_test.py

示例5: getTwitterUserStreamURL

# 需要导入模块: from oauth.oauth import OAuthRequest [as 别名]
# 或者: from oauth.oauth.OAuthRequest import from_token_and_callback [as 别名]
def getTwitterUserStreamURL():
    STREAM_URL = "https://userstream.twitter.com/2/user.json"

    access_token = Token(ACCESS_TOKEN,ACCESS_TOKEN_SECRET)
    consumer = Token(CONSUMER_KEY,CONSUMER_SECRET)

    parameters = {
        'oauth_consumer_key': CONSUMER_KEY,
        'oauth_token': access_token.key,
        'oauth_signature_method': 'HMAC-SHA1',
        'oauth_timestamp': str(int(time.time())),
        'oauth_nonce': access_token._generate_nonce(),
        'oauth_version': '1.0',
    }

    oauth_request = OAuthRequest.from_token_and_callback(access_token,
                    http_url=STREAM_URL,
                    parameters=parameters)
    signature_method = OAuthSignatureMethod_HMAC_SHA1()
    signature = signature_method.build_signature(oauth_request,
consumer, access_token)

    parameters['oauth_signature'] = signature
    data = urllib.urlencode(parameters)
    return "%s?%s" % (STREAM_URL,data)


#was used for reading from a file and debugging
#filePath = "/home/randy/TalkingSkullPhrases.txt"
#outputPath = "/home/pi/soundfiles/"
#minWaitSeconds = 5
开发者ID:rkeeling75,项目名称:TwitterTalker,代码行数:33,代码来源:skulltalker.py


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