def login_done(request): app = TwitterApp.objects.get_current() client = OAuthTwitter( request, app.consumer_key, app.consumer_secret, app.request_token_url) try: user_info = client.get_user_info() except OAuthError, e: return render_authentication_error(request)
def login_done(request): app = TwitterApp.objects.get_current() client = OAuthTwitter(request, app.consumer_key, app.consumer_secret, app.request_token_url) user_info = client.get_user_info() try: account = TwitterAccount.objects.get(social_id=user_info['id']) except TwitterAccount.DoesNotExist: account = TwitterAccount(social_id=user_info['id']) account.profile_image_url = user_info['profile_image_url'] account.username = user_info['screen_name'] if account.pk: account.save() data = dict(twitter_user_info=user_info, username=account.username) return complete_social_login(request, data, account)
def login_done(request): app = TwitterApp.objects.get_current() client = OAuthTwitter( request, app.consumer_key, app.consumer_secret, app.request_token_url) user_info = client.get_user_info() access_token = client._get_at_from_session() try: account = TwitterAccount.objects.get(social_id=user_info['id']) except TwitterAccount.DoesNotExist: account = TwitterAccount(social_id=user_info['id']) account.profile_image_url = user_info['profile_image_url'] account.username = user_info['screen_name'] account.access_token = access_token['oauth_token'] account.access_token_secret = access_token['oauth_token_secret'] if account.pk: account.save() data = dict(twitter_user_info=user_info,username=account.username) return complete_social_login(request, data, account)