Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
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)
    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 oauth_redirect(request, consumer_key=None, secret_key=None,
    request_token_url=None, access_token_url=None, authorization_url=None,
    callback_url=None, parameters=None):
    """
    View to handle the OAuth based authentication redirect to the service provider
    """
    request.session['next'] = get_login_redirect_url(request)
    client = OAuthClient(request, consumer_key, secret_key,
Пример #4
0
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)
    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 oauth_redirect(request, consumer_key=None, secret_key=None,
    request_token_url=None, access_token_url=None, authorization_url=None,
    callback_url=None, parameters=None):
    """
    View to handle the OAuth based authentication redirect to the service provider
    """
    request.session['next'] = get_login_redirect_url(request)
    client = OAuthClient(request, consumer_key, secret_key,