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


Python SocialToken.account方法代码示例

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


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

示例1: dispatch

# 需要导入模块: from allauth.socialaccount.models import SocialToken [as 别名]
# 或者: from allauth.socialaccount.models.SocialToken import account [as 别名]
 def dispatch(self, request):
     """
     View to handle final steps of OAuth based authentication where the user
     gets redirected back to from the service provider
     """
     login_done_url = reverse(self.adapter.provider_id + "_callback")
     client = self._get_client(request, login_done_url)
     if not client.is_valid():
         if 'denied' in request.GET:
             return HttpResponseRedirect(reverse('socialaccount_login_cancelled'))
         extra_context = dict(oauth_client=client)
         return render_authentication_error(request, extra_context)
     app = self.adapter.get_provider().get_app(request)
     try:
         access_token = client.get_access_token()
         token = SocialToken(app=app,
                             token=access_token['oauth_token'],
                             token_secret=access_token['oauth_token_secret'])
         login = self.adapter.complete_login(request, app, token)
         token.account = login.account
         login.token = token
         login.state = SocialLogin.unmarshall_state \
             (request.session.pop('oauth_login_state', None))
         return complete_social_login(request, login)
     except OAuthError:
         return render_authentication_error(request)
开发者ID:GVRV,项目名称:django-allauth,代码行数:28,代码来源:views.py

示例2: dispatch

# 需要导入模块: from allauth.socialaccount.models import SocialToken [as 别名]
# 或者: from allauth.socialaccount.models.SocialToken import account [as 别名]
 def dispatch(self, request):
     if 'error' in request.GET or not 'code' in request.GET:
         # TODO: Distinguish cancel from error
         return render_authentication_error(request)
     app = self.adapter.get_provider().get_app(self.request)
     client = self.get_client(request, app)
     try:
         r = praw.Reddit('OAuth Sketchdaily Schedule  by u/davidwinters ver 0.1.')
         r.set_oauth_app_info(client.consumer_key, client.consumer_secret, 'http://themes.sketchdaily.net/accounts/redditprovider/login/callback/')
         access_token = r.get_access_information(request.GET['code'])
         user = r.get_me()
         extra = r.get_my_moderation()
         # access_token = client.get_access_token(request.GET['code'])
         token = SocialToken(token=access_token)
         #token = self.adapter.parse_token(access_token)
         token.app = app
         login = self.adapter.complete_login(request,
                                             app,
                                             token,
                                             response=access_token, user=user, extra=extra)
         token.account = login.account
         login.token = token
         login.state = SocialLogin.unmarshall_state(request.REQUEST
                                                    .get('uniqueKey'))
         return complete_social_login(request, login)
     except OAuth2Error:
         return render_authentication_error(request)
开发者ID:MacAnthony,项目名称:postschedule,代码行数:29,代码来源:views.py

示例3: dispatch

# 需要导入模块: from allauth.socialaccount.models import SocialToken [as 别名]
# 或者: from allauth.socialaccount.models.SocialToken import account [as 别名]
 def dispatch(self, request):
     if 'error' in request.GET or not 'code' in request.GET:
         # TODO: Distinguish cancel from error
         return render_authentication_error(request)
     app = self.adapter.get_provider().get_app(self.request)
     client = self.get_client(request, app)
     try:
         access_token = client.get_access_token(request.GET['code'])
         token = SocialToken(app=app,
                             token=access_token)
         login = self.adapter.complete_login(request,
                                             app,
                                             token)
         token.account = login.account
         login.token = token
         return complete_social_login(request, login)
     except OAuth2Error:
         return render_authentication_error(request)
开发者ID:opkorz,项目名称:friendbook,代码行数:20,代码来源:views.py

示例4: dispatch

# 需要导入模块: from allauth.socialaccount.models import SocialToken [as 别名]
# 或者: from allauth.socialaccount.models.SocialToken import account [as 别名]
 def dispatch(self, request):
     if 'error' in request.GET or not 'code' in request.GET:
         # TODO: Distinguish cancel from error
         return render_authentication_error(request)
     app = self.adapter.get_provider().get_app(self.request)
     client = self.get_client(request, app)
     try:
         access_token, refresh_token = client.get_access_token(request.GET['code'])
         token = SocialToken(app=app,
                             token=access_token,
                             token_secret=refresh_token)
         login = self.adapter.complete_login(request, app, token)
         token.account = login.account
         login.token = token
         login.state = SocialLogin.unmarshall_state(request.REQUEST
                                                    .get('state'))
         login.redirect_account_url = request.session.pop('redirect_account_url', None)
         return complete_social_login(request, login)
     except OAuth2Error:
         return render_authentication_error(request)
开发者ID:artminster,项目名称:django-allauth,代码行数:22,代码来源:views.py


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