本文整理汇总了Python中allauth.socialaccount.providers.oauth.views.OAuthCallbackView.adapter_view方法的典型用法代码示例。如果您正苦于以下问题:Python OAuthCallbackView.adapter_view方法的具体用法?Python OAuthCallbackView.adapter_view怎么用?Python OAuthCallbackView.adapter_view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类allauth.socialaccount.providers.oauth.views.OAuthCallbackView
的用法示例。
在下文中一共展示了OAuthCallbackView.adapter_view方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DropboxAPI
# 需要导入模块: from allauth.socialaccount.providers.oauth.views import OAuthCallbackView [as 别名]
# 或者: from allauth.socialaccount.providers.oauth.views.OAuthCallbackView import adapter_view [as 别名]
from .provider import DropboxProvider
class DropboxAPI(OAuth):
"""
Verifying dropbox credentials
"""
url = 'https://api.dropbox.com/1/account/info'
def get_user_info(self):
user = json.loads(self.query(self.url))
return user
class DropboxOAuthAdapter(OAuthAdapter):
provider_id = DropboxProvider.id
request_token_url = 'https://api.dropbox.com/1/oauth/request_token'
access_token_url = 'https://api.dropbox.com/1/oauth/access_token'
authorize_url = 'https://www.dropbox.com/1/oauth/authorize'
def complete_login(self, request, app, token, response):
client = DropboxAPI(request, app.client_id, app.secret,
self.request_token_url)
extra_data = client.get_user_info()
return self.get_provider().sociallogin_from_response(request,
extra_data)
oauth_login = OAuthLoginView.adapter_view(DropboxOAuthAdapter)
oauth_callback = OAuthCallbackView.adapter_view(DropboxOAuthAdapter)
示例2: get_user_info
# 需要导入模块: from allauth.socialaccount.providers.oauth.views import OAuthCallbackView [as 别名]
# 或者: from allauth.socialaccount.providers.oauth.views.OAuthCallbackView import adapter_view [as 别名]
url = 'https://twitter.com/account/verify_credentials.json'
def get_user_info(self):
user = simplejson.loads(self.query(self.url))
return user
class TwitterOAuthAdapter(OAuthAdapter):
provider_id = TwitterProvider.id
request_token_url = 'https://api.twitter.com/oauth/request_token'
access_token_url = 'https://api.twitter.com/oauth/access_token'
# Issue #42 -- this one authenticates over and over again...
# authorize_url = 'https://api.twitter.com/oauth/authorize'
authorize_url = 'https://api.twitter.com/oauth/authenticate'
def get_user_info(self, request, app):
client = TwitterAPI(request, app.key, app.secret,
self.request_token_url)
user_info = client.get_user_info()
uid = user_info['id']
extra_data = { 'profile_image_url': user_info['profile_image_url'],
'screen_name': user_info['screen_name'] }
data = dict(twitter_user_info=user_info,
username=user_info['screen_name'])
return uid, data, extra_data
oauth_login = OAuthLoginView.adapter_view(TwitterOAuthAdapter)
oauth_callback = OAuthCallbackView.adapter_view(TwitterOAuthAdapter)
oauth_complete = OAuthCompleteView.adapter_view(TwitterOAuthAdapter)
示例3: complete_login
# 需要导入模块: from allauth.socialaccount.providers.oauth.views import OAuthCallbackView [as 别名]
# 或者: from allauth.socialaccount.providers.oauth.views.OAuthCallbackView import adapter_view [as 别名]
authorize_url = 'https://trello.com/1/OAuthAuthorizeToken'
profile_url = 'https://trello.com/1/members/me'
def complete_login(self, request, app, token):
consumer = oauth.Consumer(key=app.key, secret=app.secret)
access_token = oauth.Token(key=token.token, secret=token.token_secret)
client = oauth.Client(consumer, access_token)
client.ca_certs = certifi.where()
response, data = client.request(self.profile_url)
extra_data = json.loads(data)
full_name = extra_data.get('fullName', '').split(' ')
user = User(
username=extra_data.get('username', ''),
email=extra_data.get('email', ''),
first_name=full_name[0] if full_name else '',
last_name=full_name[1] if len(full_name) > 1 else '',
)
account = SocialAccount(
user=user,
uid=extra_data.get('id'),
extra_data=extra_data,
provider=self.provider_id
)
return SocialLogin(account)
oauth_login = OAuthLoginView.adapter_view(TrelloOAuthAdapter)
oauth_callback = OAuthCallbackView.adapter_view(TrelloOAuthAdapter)
示例4: LinkedInOAuthAdapter
# 需要导入模块: from allauth.socialaccount.providers.oauth.views import OAuthCallbackView [as 别名]
# 或者: from allauth.socialaccount.providers.oauth.views.OAuthCallbackView import adapter_view [as 别名]
out[node.tag] = [out[node.tag]]
out[node.tag].append(self.to_dict(node))
else:
out[node.tag] = self.to_dict(node)
return out
class LinkedInOAuthAdapter(OAuthAdapter):
provider_id = LinkedInProvider.id
request_token_url = 'https://api.linkedin.com/uas/oauth/requestToken'
access_token_url = 'https://api.linkedin.com/uas/oauth/accessToken'
authorize_url = 'https://www.linkedin.com/uas/oauth/authenticate'
def complete_login(self, request, app, token):
client = LinkedInAPI(request, app.client_id, app.secret,
self.request_token_url)
extra_data = client.get_user_info()
uid = extra_data['id']
user = get_adapter() \
.populate_new_user(email=extra_data.get('email-address'),
first_name=extra_data.get('first-name'),
last_name=extra_data.get('last-name'))
account = SocialAccount(user=user,
provider=self.provider_id,
extra_data=extra_data,
uid=uid)
return SocialLogin(account)
oauth_login = OAuthLoginView.adapter_view(LinkedInOAuthAdapter)
oauth_callback = OAuthCallbackView.adapter_view(LinkedInOAuthAdapter)
示例5: FiveHundredPxAPI
# 需要导入模块: from allauth.socialaccount.providers.oauth.views import OAuthCallbackView [as 别名]
# 或者: from allauth.socialaccount.providers.oauth.views.OAuthCallbackView import adapter_view [as 别名]
API_BASE = 'https://api.500px.com/v1'
class FiveHundredPxAPI(OAuth):
"""
Verifying 500px credentials
"""
url = API_BASE + '/users'
def get_user_info(self):
return json.loads(self.query(self.url))['user']
class FiveHundredPxOAuthAdapter(OAuthAdapter):
provider_id = FiveHundredPxProvider.id
request_token_url = API_BASE + '/oauth/request_token'
access_token_url = API_BASE + '/oauth/access_token'
authorize_url = API_BASE + '/oauth/authorize'
def complete_login(self, request, app, token, response):
client = FiveHundredPxAPI(request, app.client_id, app.secret,
self.request_token_url)
extra_data = client.get_user_info()
return self.get_provider().sociallogin_from_response(request,
extra_data)
oauth_login = OAuthLoginView.adapter_view(FiveHundredPxOAuthAdapter)
oauth_callback = OAuthCallbackView.adapter_view(FiveHundredPxOAuthAdapter)
示例6: get_user_info
# 需要导入模块: from allauth.socialaccount.providers.oauth.views import OAuthCallbackView [as 别名]
# 或者: from allauth.socialaccount.providers.oauth.views.OAuthCallbackView import adapter_view [as 别名]
def get_user_info(self):
# TODO: Actually turn these into EmailAddress
emails = json.loads(self.query(self.emails_url))
for address in reversed(emails):
if address['active']:
email = address['email']
if address['primary']:
break
data = json.loads(self.query(self.users_url + email))
user = data['user']
return user
class BitbucketOAuthAdapter(OAuthAdapter):
provider_id = BitbucketProvider.id
request_token_url = 'https://bitbucket.org/api/1.0/oauth/request_token'
access_token_url = 'https://bitbucket.org/api/1.0/oauth/access_token'
authorize_url = 'https://bitbucket.org/api/1.0/oauth/authenticate'
def complete_login(self, request, app, token, response):
client = BitbucketAPI(request, app.client_id, app.secret,
self.request_token_url)
extra_data = client.get_user_info()
return self.get_provider().sociallogin_from_response(request,
extra_data)
oauth_login = OAuthLoginView.adapter_view(BitbucketOAuthAdapter)
oauth_callback = OAuthCallbackView.adapter_view(BitbucketOAuthAdapter)
示例7: get_user_info
# 需要导入模块: from allauth.socialaccount.providers.oauth.views import OAuthCallbackView [as 别名]
# 或者: from allauth.socialaccount.providers.oauth.views.OAuthCallbackView import adapter_view [as 别名]
elif app_settings.PROVIDERS['kony'].get('environment', 'prod') == 'prod':
url = 'https://api.kony.com/api/v1_0/whoami'
def get_user_info(self):
raw_json = self.query(self.url, method="POST")
user_info = json.loads(raw_json)
return user_info
class KonyOAuthAdapter(OAuthAdapter):
provider_id = KonyProvider.id
if app_settings.PROVIDERS['kony'].get('environment', 'dev') == 'dev':
request_token_url = 'https://manage.dev-kony.com/oauth/request_token'
access_token_url = 'https://manage.dev-kony.com/oauth/access_token'
authorize_url = 'https://manage.dev-kony.com/oauth/authorize'
elif app_settings.PROVIDERS['kony'].get('environment', 'dev') == 'prod':
request_token_url = 'https://manage.kony.com/oauth/request_token'
access_token_url = 'https://manage.kony.com/oauth/access_token'
authorize_url = 'https://manage.kony.com/oauth/authorize'
def complete_login(self, request, app, token, response):
client = KonyAPI(request, app.client_id, app.secret,
self.request_token_url)
extra_data = client.get_user_info()
return self.get_provider().sociallogin_from_response(request,
extra_data)
oauth_login = OAuthLoginView.adapter_view(KonyOAuthAdapter)
oauth_callback = OAuthCallbackView.adapter_view(KonyOAuthAdapter)
示例8: VimeoAPI
# 需要导入模块: from allauth.socialaccount.providers.oauth.views import OAuthCallbackView [as 别名]
# 或者: from allauth.socialaccount.providers.oauth.views.OAuthCallbackView import adapter_view [as 别名]
OAuthLoginView,
OAuthCallbackView)
from .provider import VimeoProvider
class VimeoAPI(OAuth):
url = 'http://vimeo.com/api/rest/v2?method=vimeo.people.getInfo'
def get_user_info(self):
url = self.url
data = json.loads(self.query(url, params=dict(format='json')))
return data['person']
class VimeoOAuthAdapter(OAuthAdapter):
provider_id = VimeoProvider.id
request_token_url = 'https://vimeo.com/oauth/request_token'
access_token_url = 'https://vimeo.com/oauth/access_token'
authorize_url = 'https://vimeo.com/oauth/authorize'
def complete_login(self, request, app, token):
client = VimeoAPI(request, app.client_id, app.secret,
self.request_token_url)
extra_data = client.get_user_info()
return self.get_provider().sociallogin_from_response(request,
extra_data)
oauth_login = OAuthLoginView.adapter_view(VimeoOAuthAdapter)
oauth_callback = OAuthCallbackView.adapter_view(VimeoOAuthAdapter)
示例9: import
# 需要导入模块: from allauth.socialaccount.providers.oauth.views import OAuthCallbackView [as 别名]
# 或者: from allauth.socialaccount.providers.oauth.views.OAuthCallbackView import adapter_view [as 别名]
from allauth.socialaccount.providers.oauth.views import (OAuthAdapter,
OAuthLoginView,
OAuthCallbackView)
from .provider import XingProvider
class XingAPI(OAuth):
url = 'https://api.xing.com/v1/users/me.json'
def get_user_info(self):
user = json.loads(self.query(self.url))
return user
class XingOAuthAdapter(OAuthAdapter):
provider_id = XingProvider.id
request_token_url = 'https://api.xing.com/v1/request_token'
access_token_url = 'https://api.xing.com/v1/access_token'
authorize_url = 'https://www.xing.com/v1/authorize'
def complete_login(self, request, app, token, response):
client = XingAPI(request, app.client_id, app.secret,
self.request_token_url)
extra_data = client.get_user_info()['users'][0]
return self.get_provider().sociallogin_from_response(request,
extra_data)
oauth_login = OAuthLoginView.adapter_view(XingOAuthAdapter)
oauth_callback = OAuthCallbackView.adapter_view(XingOAuthAdapter)
示例10: TumblrAPI
# 需要导入模块: from allauth.socialaccount.providers.oauth.views import OAuthCallbackView [as 别名]
# 或者: from allauth.socialaccount.providers.oauth.views.OAuthCallbackView import adapter_view [as 别名]
OAuthLoginView,
)
from .provider import TumblrProvider
class TumblrAPI(OAuth):
url = 'http://api.tumblr.com/v2/user/info'
def get_user_info(self):
data = json.loads(self.query(self.url))
return data['response']['user']
class TumblrOAuthAdapter(OAuthAdapter):
provider_id = TumblrProvider.id
request_token_url = 'https://www.tumblr.com/oauth/request_token'
access_token_url = 'https://www.tumblr.com/oauth/access_token'
authorize_url = 'https://www.tumblr.com/oauth/authorize'
def complete_login(self, request, app, token, response):
client = TumblrAPI(request, app.client_id, app.secret,
self.request_token_url)
extra_data = client.get_user_info()
return self.get_provider().sociallogin_from_response(request,
extra_data)
oauth_login = OAuthLoginView.adapter_view(TumblrOAuthAdapter)
oauth_callback = OAuthCallbackView.adapter_view(TumblrOAuthAdapter)
示例11: dict
# 需要导入模块: from allauth.socialaccount.providers.oauth.views import OAuthCallbackView [as 别名]
# 或者: from allauth.socialaccount.providers.oauth.views.OAuthCallbackView import adapter_view [as 别名]
default_params = {'nojsoncallback': '1',
'format': 'json'}
p = dict({'method': 'flickr.test.login'},
**default_params)
u = json.loads(self.query(self.api_url + '?' + urlencode(p)))
p = dict({'method': 'flickr.people.getInfo',
'user_id': u['user']['id']},
**default_params)
user = json.loads(
self.query(self.api_url + '?' + urlencode(p)))
return user
class FlickrOAuthAdapter(OAuthAdapter):
provider_id = FlickrProvider.id
request_token_url = 'http://www.flickr.com/services/oauth/request_token'
access_token_url = 'http://www.flickr.com/services/oauth/access_token'
authorize_url = 'http://www.flickr.com/services/oauth/authorize'
def complete_login(self, request, app, token, response):
client = FlickrAPI(request, app.client_id, app.secret,
self.request_token_url)
extra_data = client.get_user_info()
return self.get_provider().sociallogin_from_response(request,
extra_data)
oauth_login = OAuthLoginView.adapter_view(FlickrOAuthAdapter)
oauth_callback = OAuthCallbackView.adapter_view(FlickrOAuthAdapter)
示例12: EvernoteOAuthAdapter
# 需要导入模块: from allauth.socialaccount.providers.oauth.views import OAuthCallbackView [as 别名]
# 或者: from allauth.socialaccount.providers.oauth.views.OAuthCallbackView import adapter_view [as 别名]
OAuthCallbackView,
OAuthLoginView,
)
from .provider import EvernoteProvider
class EvernoteOAuthAdapter(OAuthAdapter):
provider_id = EvernoteProvider.id
settings = app_settings.PROVIDERS.get(provider_id, {})
request_token_url = 'https://%s/oauth' % (settings.get(
'EVERNOTE_HOSTNAME',
'sandbox.evernote.com'))
access_token_url = 'https://%s/oauth' % (settings.get(
'EVERNOTE_HOSTNAME',
'sandbox.evernote.com'))
authorize_url = 'https://%s/OAuth.action' % (settings.get(
'EVERNOTE_HOSTNAME',
'sandbox.evernote.com'))
def complete_login(self, request, app, token, response):
token.expires_at = datetime.fromtimestamp(
int(response['edam_expires']) / 1000.0)
extra_data = response
return self.get_provider().sociallogin_from_response(request,
extra_data)
oauth_login = OAuthLoginView.adapter_view(EvernoteOAuthAdapter)
oauth_callback = OAuthCallbackView.adapter_view(EvernoteOAuthAdapter)
示例13: complete_login
# 需要导入模块: from allauth.socialaccount.providers.oauth.views import OAuthCallbackView [as 别名]
# 或者: from allauth.socialaccount.providers.oauth.views.OAuthCallbackView import adapter_view [as 别名]
authorize_url = 'https://websignon.warwick.ac.uk/oauth/authenticate'
def complete_login(self, request, app, token):
client = WarwickAPI(request, app.client_id, app.secret,
self.request_token_url)
extra_data = client.get_user_info()
uid = extra_data['user']
user = User(username=extra_data['user'],
email=extra_data.get('email', ''),
first_name=extra_data.get('firstname', ''),
last_name=extra_data.get('lastname', ''))
email_addresses = []
if user.email:
email_addresses.append(EmailAddress(email=user.email,
verified=True,
primary=True))
account = SocialAccount(user=user,
uid=uid,
provider=WarwickProvider.id,
extra_data=extra_data)
return SocialLogin(account, email_addresses=email_addresses)
OAuthLoginView._get_client = _get_client
OAuthCallbackView._get_client = _get_client
oauth_login = OAuthLoginView.adapter_view(WarwickOAuthAdapter)
oauth_callback = OAuthCallbackView.adapter_view(WarwickOAuthAdapter)