本文整理汇总了Python中rauth.OAuth2Service方法的典型用法代码示例。如果您正苦于以下问题:Python rauth.OAuth2Service方法的具体用法?Python rauth.OAuth2Service怎么用?Python rauth.OAuth2Service使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rauth
的用法示例。
在下文中一共展示了rauth.OAuth2Service方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_access_token
# 需要导入模块: import rauth [as 别名]
# 或者: from rauth import OAuth2Service [as 别名]
def get_access_token(self, code, *vargs, **kwargs):
long_term = kwargs.get('long_term', False)
if 'long_term' in kwargs:
del kwargs['long_term']
data = dict(
code=code,
grant_type='authorization_code',
redirect_uri=self.redirect_uri,
)
data.update(kwargs.get('data', {}))
kwargs['data'] = data
token = super(OAuth2Service, self).get_access_token(
*vargs, **kwargs)
if long_term:
token = self.get_long_term_token(token)
return token
示例2: get_oauth_services
# 需要导入模块: import rauth [as 别名]
# 或者: from rauth import OAuth2Service [as 别名]
def get_oauth_services():
oauth_services = {}
oauth_services['google'] = OAuth2Service(**oauth_config(current_app.config, 'google'))
oauth_services['github'] = OAuth2Service(**oauth_config(current_app.config, 'github'))
return oauth_services
示例3: __init__
# 需要导入模块: import rauth [as 别名]
# 或者: from rauth import OAuth2Service [as 别名]
def __init__(self):
super(FacebookSignIn, self).__init__('facebook')
self.service = OAuth2Service(
name='facebook',
client_id=self.consumer_id,
client_secret=self.consumer_secret,
authorize_url='https://graph.facebook.com/oauth/authorize',
access_token_url='https://graph.facebook.com/oauth/access_token',
base_url='https://graph.facebook.com/'
)
示例4: init
# 需要导入模块: import rauth [as 别名]
# 或者: from rauth import OAuth2Service [as 别名]
def init(client_id, client_secret, session_key='musicbrainz'):
global _musicbrainz, _session_key
_musicbrainz = OAuth2Service(
name='musicbrainz',
base_url="https://musicbrainz.org/",
authorize_url="https://musicbrainz.org/oauth2/authorize",
access_token_url="https://musicbrainz.org/oauth2/token",
client_id=client_id,
client_secret=client_secret,
)
_session_key = session_key
示例5: __init__
# 需要导入模块: import rauth [as 别名]
# 或者: from rauth import OAuth2Service [as 别名]
def __init__(self, current_app):
google_params = self._get_google_info()
self.service = OAuth2Service(
name='google',
client_id=conf.login['GOOGLE_LOGIN_CLIENT_ID'],
client_secret=conf.login['GOOGLE_LOGIN_CLIENT_SECRET'],
authorize_url=google_params.get('authorization_endpoint'),
base_url=google_params.get('userinfo_endpoint'),
access_token_url=google_params.get('token_endpoint')
)
示例6: __init__
# 需要导入模块: import rauth [as 别名]
# 或者: from rauth import OAuth2Service [as 别名]
def __init__(self, keyfile, tokenfile=None,
base_url="https://fantasysports.yahooapis.com",
request_period=0):
self.key = ClientKey.from_file(keyfile)
self.tokenfile = tokenfile
if self.tokenfile and os.path.exists(self.tokenfile):
self.token = Token.from_file(self.tokenfile)
else:
self.token = Token()
self.oauth = OAuth2Service(
client_id=self.key.client_id,
client_secret=self.key.client_secret,
name="yahoo",
authorize_url="https://api.login.yahoo.com/oauth2/request_auth",
access_token_url="https://api.login.yahoo.com/oauth2/get_token",
base_url=base_url,
)
self.session = None
self._update_token()
self.session = self.oauth.get_session(self.token.access_token)
self.last_request = time.time()
self.request_period = request_period
示例7: __init__
# 需要导入模块: import rauth [as 别名]
# 或者: from rauth import OAuth2Service [as 别名]
def __init__(self, *vargs, **kwargs):
options = dict(
authorize_url='https://graph.facebook.com/oauth/authorize',
access_token_url='https://graph.facebook.com/oauth/access_token',
base_url='https://graph.facebook.com/',
)
options.update(**kwargs)
self.redirect_uri = options.get('redirect_uri')
if 'redirect_uri' in options:
del options['redirect_uri']
super(OAuth2Service, self).__init__(*vargs, **options)
示例8: get_authorize_url
# 需要导入模块: import rauth [as 别名]
# 或者: from rauth import OAuth2Service [as 别名]
def get_authorize_url(self, *vargs, **kwargs):
options = dict(
scope='manage_pages,read_insights',
response_type='code',
redirect_uri=self.redirect_uri,
)
options.update(**kwargs)
return super(OAuth2Service, self).get_authorize_url(*vargs, **options)
示例9: authorize
# 需要导入模块: import rauth [as 别名]
# 或者: from rauth import OAuth2Service [as 别名]
def authorize(client_id, client_secret):
facebook = OAuth2Service(
client_id=client_id,
client_secret=client_secret,
redirect_uri=REDIRECT_URI,
)
user_token = authorize_user(facebook, long_term=True)
page_tokens = authorize_pages(facebook, user_token)
return page_tokens