本文整理汇总了Python中rauth.OAuth1Service方法的典型用法代码示例。如果您正苦于以下问题:Python rauth.OAuth1Service方法的具体用法?Python rauth.OAuth1Service怎么用?Python rauth.OAuth1Service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rauth
的用法示例。
在下文中一共展示了rauth.OAuth1Service方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import rauth [as 别名]
# 或者: from rauth import OAuth1Service [as 别名]
def __init__(self, app_key, app_secret, user_social_auth):
"""Constructor for YahooOAuthClient
`app_key` - Yahoo App Key
`app_secret` - Yahoo App Secret
`user_social_auth` - UserSocialAuth model to store refreshed token
"""
# UserSocialAuth needed to access the access token
self.last_error = None
self.user_social_auth = user_social_auth
self.access_token = user_social_auth.extra_data.get('access_token')
self.oauth = OAuth1Service(
name='Yahoo',
consumer_key=app_key,
consumer_secret=app_secret,
request_token_url=YAHOO_OAUTH_REQUEST_TOKEN_URL,
access_token_url=YAHOO_OAUTH_ACCESS_TOKEN_URL,
authorize_url=YAHOO_OAUTH_AUTHORIZE_URL,
)
self.session = self.oauth.get_session((self.access_token['oauth_token'], self.access_token['oauth_token_secret']))
示例2: __osm_auth_service
# 需要导入模块: import rauth [as 别名]
# 或者: from rauth import OAuth1Service [as 别名]
def __osm_auth_service() -> OAuth1Service:
"""Factory method that builds osm auth service"""
osm = OAuth1Service(
name='openstreetmap',
consumer_key='rBWV8Eaottv44tXfdLofdNvVemHOL62Lsutpb9tw',
consumer_secret='rpmeZIp49sEjjcz91X9dsY0vD1PpEduixuPy8T6S',
request_token_url='https://www.openstreetmap.org/oauth/request_token',
access_token_url='https://www.openstreetmap.org/oauth/access_token',
authorize_url='https://www.openstreetmap.org/oauth/authorize',
signature_obj='',
base_url='https://www.openstreetmap.org/')
return osm
示例3: __init__
# 需要导入模块: import rauth [as 别名]
# 或者: from rauth import OAuth1Service [as 别名]
def __init__(self):
super(TwitterSignIn, self).__init__('twitter')
self.service = OAuth1Service(
name='twitter',
consumer_key=self.consumer_id,
consumer_secret=self.consumer_secret,
request_token_url='https://api.twitter.com/oauth/request_token',
authorize_url='https://api.twitter.com/oauth/authorize',
access_token_url='https://api.twitter.com/oauth/access_token',
base_url='https://api.twitter.com/1.1/'
)
示例4: create_api_key
# 需要导入模块: import rauth [as 别名]
# 或者: from rauth import OAuth1Service [as 别名]
def create_api_key():
""" Interactively create a new API key via Zotero's OAuth API.
Requires the user to enter a verification key displayed in the browser.
:returns: API key and the user's library ID
"""
auth = OAuth1Service(
name='zotero',
consumer_key=CLIENT_KEY,
consumer_secret=CLIENT_SECRET,
request_token_url=REQUEST_TOKEN_URL,
access_token_url=ACCESS_TOKEN_URL,
authorize_url=AUTH_URL,
base_url=BASE_URL)
token, secret = auth.get_request_token(
params={'oauth_callback': 'oob'})
auth_url = auth.get_authorize_url(token)
auth_url += '&' + urlencode({
'name': 'zotero-cli',
'library_access': 1,
'notes_access': 1,
'write_access': 1,
'all_groups': 'read'})
click.echo("Opening {} in browser, please confirm.".format(auth_url))
click.launch(auth_url)
verification = click.prompt("Enter verification code")
token_resp = auth.get_raw_access_token(
token, secret, method='POST',
data={'oauth_verifier': verification})
if not token_resp:
logging.debug(token_resp.content)
click.fail("Error during API key generation.")
access = urlparse.parse_qs(token_resp.text)
return access['oauth_token'][0], access['userID'][0]