示例#1
0
def plaid_authorize_callback(request):
    print "plaid_authorize_callback"
    #print request.user.username
    code = request.GET.get('code')
    # print "code = "
    # print [code] 
    content = PlaidHelper.get_access_token(code)

    try:
        print [request.user.username]
        currentuser = User.objects.get(username=request.user.username)
        amexuser, created = AmexUser.get_or_create(neemi_user=currentuser) 
        print [currentuser]
        print[amexuser]
        if not currentuser.is_authenticated():
            print "ohoh Not Authenticated"
        else:
            print "updating user"
            amexuser.access_token = content['access_token']
            currentuser.add_plaid_service('amex')#only one option for now

    except DoesNotExist:
        print "DOesNotExist"
    print "Called back"

    return HttpResponseRedirect('/register/')
示例#2
0
def plaid_authorize_callback(request):
    print "plaid_authorize_callback"
    #print request.user.username
    code = request.GET.get('code')
    # print "code = "
    # print [code]
    content = PlaidHelper.get_access_token(code)

    try:
        print[request.user.username]
        currentuser = User.objects.get(username=request.user.username)
        amexuser, created = AmexUser.get_or_create(neemi_user=currentuser)
        print[currentuser]
        print[amexuser]
        if not currentuser.is_authenticated():
            print "ohoh Not Authenticated"
        else:
            print "updating user"
            amexuser.access_token = content['access_token']
            currentuser.add_plaid_service('amex')  #only one option for now

    except DoesNotExist:
        print "DOesNotExist"
    print "Called back"

    return HttpResponseRedirect('/register/')
示例#3
0
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)
示例#4
0
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)