Esempio n. 1
0
def foursquare_authorize_callback(request):
    print "foursquare_authorize_callback"
    print request

    if 'code' in request.GET:
        oauth_code = request.GET.get('code')
    else:
        print "Missing oauth code!"
        return

    access_token = FoursquareHelper.get_access_token(oauth_code)

    try:
        print [request.user.username]
        currentuser = User.objects.get(username=request.user.username)
        foursquareuser, created = FoursquareUser.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({'foursquare'})

            print "access_token: ", access_token
            
            foursquareuser.access_token = access_token
            foursquareuser.save()

    except DoesNotExist:
        print "DOesNotExist"
    print "Called back"
    return HttpResponseRedirect('/register/')
Esempio n. 2
0
def foursquare_authorize_callback(request):
    print "foursquare_authorize_callback"
    print request

    if 'code' in request.GET:
        oauth_code = request.GET.get('code')
    else:
        print "Missing oauth code!"
        return

    access_token = FoursquareHelper.get_access_token(oauth_code)

    try:
        print[request.user.username]
        currentuser = User.objects.get(username=request.user.username)
        foursquareuser, created = FoursquareUser.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({'foursquare'})

            print "access_token: ", access_token

            foursquareuser.access_token = access_token
            foursquareuser.save()

    except DoesNotExist:
        print "DOesNotExist"
    print "Called back"
    return HttpResponseRedirect('/register/')
Esempio n. 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)
Esempio n. 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)