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


Python OAuthRequest.to_postdata方法代码示例

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


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

示例1: updateProfile

# 需要导入模块: from oauth.oauth import OAuthRequest [as 别名]
# 或者: from oauth.oauth.OAuthRequest import to_postdata [as 别名]
def updateProfile(token, secret, update_profile_url, profile):
    current_site = Site.objects.get_current()
    user_profile_url = "%s%s" % (current_site.domain, reverse('profile_detail', args=[profile.user.username]))
    oauthToken = OAuthToken(token, secret)
    url = urlparse.urlparse(update_profile_url)
    params = {}
    if url[4] != '':
        # We need to copy over the query string params for sites like laconica
        params.update(dict([part.split('=') for part in url[4].split('&')]))
    params['omb_version'] = OMB_VERSION_01
    params['omb_listenee'] = user_profile_url
    params['omb_listenee_profile'] = user_profile_url
    params['omb_listenee_nickname'] = profile.username
    params['omb_listenee_license'] = '%s/license/' % current_site.domain # TODO link to the real license
    params['omb_listenee_fullname'] = profile.name
    params['omb_listenee_homepage'] = profile.website
    params['omb_listenee_bio'] = profile.about
    params['omb_listenee_location'] = profile.location
    #params['omb_listenee_avatar'] = TODO get the gravatar of the user
    
    consumer = OAuthConsumer(current_site.domain, "")
    req = OAuthRequest().from_consumer_and_token(consumer, token=oauthToken, http_url=url.geturl(), parameters=params, http_method="POST")
    req.sign_request(OAuthSignatureMethod_HMAC_SHA1(), consumer, oauthToken)
    f = urllib.urlopen(url.geturl(), req.to_postdata())
    data = f.read()
    # TODO log failures
开发者ID:duy,项目名称:django-omb,代码行数:28,代码来源:oauthConsumer.py

示例2: requestToken

# 需要导入模块: from oauth.oauth import OAuthRequest [as 别名]
# 或者: from oauth.oauth.OAuthRequest import to_postdata [as 别名]
def requestToken(omb):
    current_site = Site.objects.get_current()
    url = urlparse.urlparse(omb[OAUTH_REQUEST].uris[0].uri)
    params = {}
    if url[4] != '':
        # We need to copy over the query string params for sites like laconica
        params.update(dict([part.split('=') for part in url[4].split('&')]))
    params['omb_version'] = OMB_VERSION_01
    params['omb_listener'] = omb[OAUTH_REQUEST].localid.text
    consumer = OAuthConsumer(current_site.domain, "")
    req = OAuthRequest().from_consumer_and_token(consumer, http_url=url.geturl(), parameters=params, http_method="POST")
    req.sign_request(OAuthSignatureMethod_HMAC_SHA1(), consumer, None)
    f = urllib.urlopen(url.geturl(), req.to_postdata())
    data = f.read()
    requestToken = OAuthToken.from_string(data)
    return requestToken
开发者ID:duy,项目名称:django-omb,代码行数:18,代码来源:oauthConsumer.py

示例3: requestAccessToken

# 需要导入模块: from oauth.oauth import OAuthRequest [as 别名]
# 或者: from oauth.oauth.OAuthRequest import to_postdata [as 别名]
def requestAccessToken(omb_session, oauth_request):
    current_site = Site.objects.get_current()
    token = OAuthToken(omb_session["token"], omb_session["secret"])
    url = urlparse.urlparse(omb_session["access_token_url"])
    params = {}
    if url[4] != '':
        # We need to copy over the query string params for sites like laconica
        params.update(dict([part.split('=') for part in url[4].split('&')]))
    params['omb_version'] = OMB_VERSION_01
    consumer = OAuthConsumer(current_site.domain, "")
    req = OAuthRequest().from_consumer_and_token(consumer, token=token, http_url=url.geturl(), parameters=params, http_method="POST")
    req.sign_request(OAuthSignatureMethod_HMAC_SHA1(), consumer, token)
    f = urllib.urlopen(url.geturl(), req.to_postdata())
    data = f.read()
    accessToken = OAuthToken.from_string(data)
    return accessToken
开发者ID:duy,项目名称:django-omb,代码行数:18,代码来源:oauthConsumer.py

示例4: start_auth

# 需要导入模块: from oauth.oauth import OAuthRequest [as 别名]
# 或者: from oauth.oauth.OAuthRequest import to_postdata [as 别名]
def start_auth(request, fail_redirect='/account/other_services/'):
    consumer = OAuthConsumer(settings.TWITTER_CONSUMER_KEY, settings.TWITTER_CONSUMER_SECRET)
    # Request the OAuth Token
    req = OAuthRequest().from_consumer_and_token(consumer, http_url=TWITTER_REQUEST_TOKEN_URL,
        parameters={}, http_method="POST")
    req.sign_request(OAuthSignatureMethod_HMAC_SHA1(), consumer, None)
    try:
        res = urllib.urlopen(TWITTER_REQUEST_TOKEN_URL, req.to_postdata())
        requestToken = OAuthToken.from_string(res.read())
        # Authorise the OAuth Token
        oauth_request = OAuthRequest().from_consumer_and_token(consumer, http_url=TWITTER_AUTHORIZE_URL, 
            parameters={}, http_method="GET", token=requestToken)
        oauth_request.sign_request(OAuthSignatureMethod_HMAC_SHA1(), consumer, requestToken)
        return HttpResponseRedirect(oauth_request.to_url())
    except IOError:
        request.user.message_set.create(
            message=ugettext(u"Twitter authorization failed.")
        )
        return HttpResponseRedirect(fail_redirect)
开发者ID:skabber,项目名称:django-twitterauth,代码行数:21,代码来源:views.py

示例5: postNotice

# 需要导入模块: from oauth.oauth import OAuthRequest [as 别名]
# 或者: from oauth.oauth.OAuthRequest import to_postdata [as 别名]
def postNotice(token, secret, post_notice_url, notice_content, notice_url, user):
    current_site = Site.objects.get_current()
    user_profile_url = "%s%s" % (current_site.domain, reverse('profile_detail', args=[user.username]))
    oauthToken = OAuthToken(token, secret)
    url = urlparse.urlparse(post_notice_url)
    params = {}
    if url[4] != '':
        # We need to copy over the query string params for sites like laconica
        params.update(dict([part.split('=') for part in url[4].split('&')]))
    params['omb_version'] = OMB_VERSION_01
    params['omb_listenee'] = user_profile_url
    params['omb_notice'] = "%s%s" % (current_site.domain, notice_url)
    params['omb_notice_content'] = notice_content
    params['omb_notice_url'] = "%s%s" % (current_site.domain, notice_url)
    params['omb_notice_license'] = '%s/license/' % current_site.domain # TODO link to the real license
    
    consumer = OAuthConsumer(current_site.domain, "")
    req = OAuthRequest().from_consumer_and_token(consumer, token=oauthToken, http_url=url.geturl(), parameters=params, http_method="POST")
    req.sign_request(OAuthSignatureMethod_HMAC_SHA1(), consumer, oauthToken)
    f = urllib.urlopen(url.geturl(), req.to_postdata())
    data = f.read()
开发者ID:duy,项目名称:django-omb,代码行数:23,代码来源:oauthConsumer.py

示例6: get_credentials_from_request

# 需要导入模块: from oauth.oauth import OAuthRequest [as 别名]
# 或者: from oauth.oauth.OAuthRequest import to_postdata [as 别名]
def get_credentials_from_request(request):
    token = OAuthToken(request.GET.get("oauth_token"), "")
    consumer = OAuthConsumer(settings.TWITTER_CONSUMER_KEY, settings.TWITTER_CONSUMER_SECRET)
    oauth_request = OAuthRequest().from_consumer_and_token(consumer, http_url=TWITTER_REQUEST_ACCESS_TOKEN_URL,
        parameters={}, http_method="GET", token=token)
    oauth_request.sign_request(OAuthSignatureMethod_HMAC_SHA1(), consumer, token)
    try:
        res = urllib.urlopen(TWITTER_REQUEST_ACCESS_TOKEN_URL, oauth_request.to_postdata())
        accessToken = OAuthToken.from_string(res.read())
        # verify the access token
        verify_request = OAuthRequest().from_consumer_and_token(consumer, http_url=TWITTER_VERIFY_CREDENTIALS,
            http_method="GET", token=accessToken)
        verify_request.sign_request(OAuthSignatureMethod_HMAC_SHA1(), consumer, accessToken)
        res = urllib.urlopen(verify_request.to_url())
        json_response = simplejson.loads(res.read())
        if json_response['screen_name']:
            return accessToken
            request.user.message_set.create(
                message=ugettext(u"Twitter authorization failed.")
            )
    except IOError:
        request.user.message_set.create(
            message=ugettext(u"Twitter authorization failed.")
        )
开发者ID:skabber,项目名称:django-twitterauth,代码行数:26,代码来源:views.py


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