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


Python views.OAuthLoginView类代码示例

本文整理汇总了Python中allauth.socialaccount.providers.oauth.views.OAuthLoginView的典型用法代码示例。如果您正苦于以下问题:Python OAuthLoginView类的具体用法?Python OAuthLoginView怎么用?Python OAuthLoginView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: DropboxAPI

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)
开发者ID:ad-m,项目名称:django-allauth,代码行数:30,代码来源:views.py

示例2: get_user_info

    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)
开发者ID:chhabrakadabra,项目名称:django-allauth,代码行数:30,代码来源:views.py

示例3: complete_login

    access_token_url = 'https://trello.com/1/OAuthGetAccessToken'
    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)
开发者ID:rawjam,项目名称:django-allauth,代码行数:31,代码来源:views.py

示例4: LinkedInOAuthAdapter

                        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)
开发者ID:Gussy,项目名称:django-allauth,代码行数:30,代码来源:views.py

示例5: FiveHundredPxAPI

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)
开发者ID:ad-m,项目名称:django-allauth,代码行数:29,代码来源:views.py

示例6: get_user_info

    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)
开发者ID:biwin,项目名称:django-allauth,代码行数:29,代码来源:views.py

示例7: get_user_info

    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)
开发者ID:concentricsky,项目名称:badgr-server,代码行数:30,代码来源:views.py

示例8: VimeoAPI

                                                         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)
开发者ID:400yk,项目名称:Ejub,代码行数:30,代码来源:views.py

示例9: TumblrAPI

    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)
开发者ID:biwin,项目名称:django-allauth,代码行数:30,代码来源:views.py

示例10: import

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)
开发者ID:APSL,项目名称:django-allauth,代码行数:30,代码来源:views.py

示例11: get_user_info

    def get_user_info(self):
        user = json.loads(self.query(self.url))
        #user_avatar = json.loads(self.query(self.url_avatar))
        user_shops = json.loads(self.query(self.url_shops))
        user_profile = json.loads(self.query(self.url_profile))

        data = {"user": user["results"][0], "profile": user_profile["results"][0], "shops": user_shops["results"]}

        return data


class EtsyOAuthAdapter(OAuthAdapter):
    provider_id = EtsyProvider.id
    request_token_url = 'https://openapi.etsy.com/v2/oauth/request_token'
    access_token_url = 'https://openapi.etsy.com/v2/oauth/access_token'
    # Issue #42 -- this one authenticates over and over again...
    # authorize_url = 'https://api.twitter.com/oauth/authorize'
    authorize_url = 'https://www.etsy.com/oauth/signin'

    def complete_login(self, request, app, token):
        client = EtsyAPI(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(EtsyOAuthAdapter)
oauth_callback = OAuthCallbackView.adapter_view(EtsyOAuthAdapter)
开发者ID:joebos,项目名称:django-allauth,代码行数:29,代码来源:views.py

示例12: dict

        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)
开发者ID:ad-m,项目名称:django-allauth,代码行数:30,代码来源:views.py

示例13: TwitterOAuthAdapter


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 complete_login(self, request, app, token):
        client = TwitterAPI(request, app.client_id, app.secret,
                            self.request_token_url)
        extra_data = client.get_user_info()
        uid = extra_data['id']
        user = User(username=extra_data['screen_name'])
        account = SocialAccount(user=user,
                                uid=uid,
                                provider=TwitterProvider.id,
                                extra_data=extra_data)
        return SocialLogin(account)

class TwitterFullAuthorizationAdapter(TwitterOAuthAdapter):
    authorize_url = 'https://api.twitter.com/oauth/authorize'


oauth_authorize = OAuthLoginView.adapter_view(TwitterFullAuthorizationAdapter)
oauth_login = OAuthLoginView.adapter_view(TwitterOAuthAdapter)
oauth_callback = OAuthCallbackView.adapter_view(TwitterOAuthAdapter)

开发者ID:ksze,项目名称:django-allauth,代码行数:27,代码来源:views.py

示例14: EvernoteOAuthAdapter

    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)
开发者ID:biwin,项目名称:django-allauth,代码行数:30,代码来源:views.py

示例15: complete_login

    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)

开发者ID:thomaspurchas,项目名称:django-allauth,代码行数:29,代码来源:views.py


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