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


Python SmugMug.auth_getRequestToken方法代码示例

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


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

示例1: TestOauth

# 需要导入模块: from smugpy import SmugMug [as 别名]
# 或者: from smugpy.SmugMug import auth_getRequestToken [as 别名]
class TestOauth(unittest.TestCase):
    def setUp(self):
        self.smugmug = SmugMug(api_key=API_KEY, api_version='1.3.0', app_name='TestApp', oauth_secret=OAUTH_SECRET)

    def test_get_request_token(self):
        self.smugmug.auth_getRequestToken()
        self.assertNotEqual(self.smugmug.oauth_token, None)
        self.assertNotEqual(self.smugmug.oauth_token_secret, None)
        self.smugmug.reset_auth()

    def test_get_access_token(self):
        self.smugmug.auth_getAccessToken()
        self.assertNotEqual(self.smugmug.oauth_token, None)
        self.assertNotEqual(self.smugmug.oauth_token_secret, None)
        self.smugmug.reset_auth()

    def test_request_signature(self):
        url = 'http://api.smugmug.com/services/api/json/'
        parameters = dict(
            method = 'smugmug.albums.get',
            NickName = 'williams'
        )
        timestamp = 1341423551
        nonce = 'b7cdabcabc3c4f7f91508da3bca9798f'
        signed_args = self.smugmug._get_oauth_request_params(url=url, parameters=parameters, method='POST', timestamp=timestamp, nonce=nonce)
        self.assertEqual(signed_args['oauth_signature'], 'f++GOXf9BhSVhGy1dxGSbmaA0ng=')
开发者ID:chrishoffman,项目名称:smugpy,代码行数:28,代码来源:test_oauth.py

示例2: smug_auth

# 需要导入模块: from smugpy import SmugMug [as 别名]
# 或者: from smugpy.SmugMug import auth_getRequestToken [as 别名]
def smug_auth():
    smugmug = SmugMug(api_key=config.get('smugmug', 'key'), oauth_secret=config.get('smugmug', 'secret'), api_version="1.3.0", app_name="flickr-to-smugmug")
    if config.has_option('smugmug', 'oauth_token'):
        smugmug.set_oauth_token(config.get('smugmug', 'oauth_token'), config.get('smugmug', 'oauth_token_secret'))
    else:
        smugmug.auth_getRequestToken()
        get_input("Authorize app at %s\n\nPress Enter when complete.\n" % (smugmug.authorize(access='Full', perm='Modify')))
        smugmug.auth_getAccessToken()
        config.set('smugmug', 'oauth_token', smugmug.oauth_token)
        config.set('smugmug', 'oauth_token_secret', smugmug.oauth_token_secret)
        save()
    return smugmug
开发者ID:Ramblurr,项目名称:smugtools,代码行数:14,代码来源:common.py

示例3: _smugmugOauthRequestToken

# 需要导入模块: from smugpy import SmugMug [as 别名]
# 或者: from smugpy.SmugMug import auth_getRequestToken [as 别名]
    def _smugmugOauthRequestToken(self, access="Public", perm="Read"):
        smugmug = SmugMug(api_key=self.api_key, oauth_secret=self.oauth_secret, app_name=self.app_name)

        # Get a token that is short-lived (probably about 5 minutes) and can be used
        # only to setup authorization at SmugMug
        response = smugmug.auth_getRequestToken()

        # Get the URL that the user must visit to authorize this app (implicilty includes the request token in the URL)
        url = smugmug.authorize(access=access, perm=perm)
        return url, response['Auth']  # (should contain a 'Token')
开发者ID:huynle,项目名称:smugphoto,代码行数:12,代码来源:auth.py

示例4: smugmugOauthGetAccessToken

# 需要导入模块: from smugpy import SmugMug [as 别名]
# 或者: from smugpy.SmugMug import auth_getRequestToken [as 别名]
def smugmugOauthGetAccessToken(requestToken):
    # Use the request token to log in (which should be authorized now)
    smugmug = SmugMug(api_key=API_KEY, oauth_secret=OAUTH_SECRET,
                      oauth_token=requestToken['Token']['id'],
                      oauth_token_secret=requestToken['Token']['Secret'],
                      app_name=APP_NAME)
 
    # The request token is good for 1 operation: to get an access token.
    response = smugmug.auth_getRequestToken()

    # The access token should be good until the user explicitly
    # disables it at smugmug.com in their settings panel.
    return response['Auth'];
开发者ID:rootbeer,项目名称:smugpy,代码行数:15,代码来源:example-oauth.py

示例5: SmugMug

# 需要导入模块: from smugpy import SmugMug [as 别名]
# 或者: from smugpy.SmugMug import auth_getRequestToken [as 别名]
#!/usr/bin/env python

from __future__ import print_function
from smugpy import SmugMug
import sys

#Aliasing for differences in Python 2.x and 3.x
if sys.version_info < (3,):
    get_input = raw_input
else:
    get_input = input

API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXX"
OAUTH_SECRET = "YYYYYYYYYYYYYYYYYYYYYYY"

smugmug = SmugMug(api_key=API_KEY, oauth_secret=OAUTH_SECRET, app_name="TestApp")

#Oauth handshake
smugmug.auth_getRequestToken()
get_input("Authorize app at %s\n\nPress Enter when complete.\n" % (smugmug.authorize()))   
smugmug.auth_getAccessToken()

albums = smugmug.albums_get(NickName="williams") # Moon River Photography, thanks Andy!
for album in albums["Albums"]:
    print("%s, %s" % (album["id"], album["Title"]))
开发者ID:Ramblurr,项目名称:smugpy,代码行数:27,代码来源:example-oauth.py


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