def twitter_authorize_callback(request): print "twitter_authorize_callback" print request if 'oauth_verifier' in request.GET: oauth_verifier = request.GET.get('oauth_verifier') access_token, access_token_secret, userid, screenname = TwitterHelper.get_access_token(oauth_verifier) try: print [request.user.username] currentuser = User.objects.get(username=request.user.username) twitteruser, created = TwitterUser.objects.get_or_create(neemi_user=currentuser) print [currentuser] if not currentuser.is_authenticated(): print "ohoh Not Authenticated" else: print "updating user" currentuser.set_services({'twitter'}) print "access_token: ", access_token print "access_token_secret: ", access_token_secret print "userid: ", userid print "screenname: ", screenname twitteruser.access_token_key = access_token twitteruser.access_token_secret = access_token_secret twitteruser.userid = userid twitteruser.screenname = screenname twitteruser.save() except DoesNotExist: print "DOesNotExist" print "Called back" return HttpResponseRedirect('/register/')
def authenticate_redirect(request, service): print "auth_redirect" print[service] print request.user print request.COOKIES['sessionid'] try: if request.user.is_authenticated(): print "authenticated" if service == 'amex': current_plaid_helper = PlaidHelper() url = current_plaid_helper.get_authorize_url() elif service == 'dropbox': current_dropbox_helper = DropboxHelper() url = current_dropbox_helper.get_authorize_url(service) print url elif service == 'twitter': current_twitter_helper = TwitterHelper() url = current_twitter_helper.get_authorize_url(service) elif service == 'linkedin': current_linkedin_helper = LinkedInHelper() url = current_linkedin_helper.get_authorize_url(service) elif service == 'foursquare': current_foursquare_helper = FoursquareHelper() url = current_foursquare_helper.get_authorize_url(service) elif service == 'facebook': current_facebook_helper = FacebookHelper() url = current_facebook_helper.get_authorize_url() elif service == 'gcal' or service == 'googledrive' or service == 'googleplus' or service == 'gmail' or service == 'googlecontacts': request.session['google_service'] = service current_google_helper = GoogleHelper() url = current_google_helper.get_authorize_url(request=request, service=service) else: print "SERVICE DOES NOT EXIST!" return HttpResponseRedirect('/register/') # return HttpRespocurrentuser.set_services({'facebook'})nseRedirect('/register/') else: print "USER NOT AUTHENTICATED" return HttpResponseRedirect('/register/') except Exception as e: print "ERROR: ", e print[url] return HttpResponseRedirect(url)
def authenticate_redirect(request, service): print "auth_redirect" print [service] print request.user print request.COOKIES['sessionid'] try: if request.user.is_authenticated(): print "authenticated" if service == 'amex': current_plaid_helper = PlaidHelper() url = current_plaid_helper.get_authorize_url() elif service == 'dropbox': current_dropbox_helper = DropboxHelper() url = current_dropbox_helper.get_authorize_url(service) print url elif service == 'twitter': current_twitter_helper = TwitterHelper() url = current_twitter_helper.get_authorize_url(service) elif service == 'linkedin': current_linkedin_helper = LinkedInHelper() url = current_linkedin_helper.get_authorize_url(service) elif service == 'foursquare': current_foursquare_helper = FoursquareHelper() url = current_foursquare_helper.get_authorize_url(service) elif service == 'facebook': current_facebook_helper = FacebookHelper() url = current_facebook_helper.get_authorize_url() elif service == 'gcal' or service == 'googledrive' or service == 'googleplus' or service == 'gmail' or service == 'googlecontacts': request.session['google_service']=service current_google_helper = GoogleHelper() url = current_google_helper.get_authorize_url(request=request, service=service) else: print "SERVICE DOES NOT EXIST!" return HttpResponseRedirect('/register/') # return HttpRespocurrentuser.set_services({'facebook'})nseRedirect('/register/') else: print "USER NOT AUTHENTICATED" return HttpResponseRedirect('/register/') except Exception as e: print "ERROR: ", e print [url] return HttpResponseRedirect(url)
def twitter_authorize_callback(request): print "twitter_authorize_callback" print request if 'oauth_verifier' in request.GET: oauth_verifier = request.GET.get('oauth_verifier') access_token, access_token_secret, userid, screenname = TwitterHelper.get_access_token( oauth_verifier) try: print[request.user.username] currentuser = User.objects.get(username=request.user.username) twitteruser, created = TwitterUser.objects.get_or_create( neemi_user=currentuser) print[currentuser] if not currentuser.is_authenticated(): print "ohoh Not Authenticated" else: print "updating user" currentuser.set_services({'twitter'}) print "access_token: ", access_token print "access_token_secret: ", access_token_secret print "userid: ", userid print "screenname: ", screenname twitteruser.access_token_key = access_token twitteruser.access_token_secret = access_token_secret twitteruser.userid = userid twitteruser.screenname = screenname twitteruser.save() except DoesNotExist: print "DOesNotExist" print "Called back" return HttpResponseRedirect('/register/')