Exemple #1
0
def incoming_twilio_phone_client_loader(request):
    from twilio.util import TwilioCapability
    account_sid = "AC260e405c96ce1eddffbddeee43a13004"
    auth_token = "fd219130e257e25e78613adc6c003d1a"
    capability = TwilioCapability(account_sid, auth_token)
    capability.allow_client_incoming(str(request.user.username))
    return render(request, 'comm/incoming_phone.html', locals())
def token():
    account_sid = os.environ.get("ACCOUNT_SID", ACCOUNT_SID)
    auth_token = os.environ.get("AUTH_TOKEN", AUTH_TOKEN)
    app_sid = os.environ.get("APP_SID", APP_SID)

    capability = TwilioCapability(account_sid, auth_token)

    # This allows outgoing connections to TwiML application
    if request.values.get("allowOutgoing") != "false":
        capability.allow_client_outgoing(app_sid)

    # This allows incoming connections to client (if specified)
    # client = request.values.get('client')
    client = "simon"  # test client fixe
    if client != None:
        capability.allow_client_incoming(client)

    # This returns a token to use with Twilio based on the account and capabilities defined above
    ##### GC return TOKEN in JSON
    # print 'Content-Type: application/json\n\n'
    # twilphonetoken = capability.generate()
    # json_data = '{"twilioToken":' + json.dumps(twilphonetoken) + '}'
    # callback = request.values.get('callback')
    # return '%s(%s)' % (callback, json_data)
    #####

    # This returns a token to use with Twilio based on the account and capabilities defined above
    return capability.generate()
Exemple #3
0
def auth():
    capability = TwilioCapability(app.config['TWILIO_ACCOUNT_SID'],
        app.config['TWILIO_AUTH_TOKEN'])
    capability.allow_client_incoming("swarm_user")
    capability.allow_client_outgoing(app.config['TWILIO_APP_SID'])
    token = capability.generate()
    return str(token)
Exemple #4
0
def get_capability():
    user = g.user
    capability = TwilioCapability(current_app.config['TWILIO_ACCOUNT_SID'],
                                         current_app.config['TWILIO_AUTH_TOKEN'])
    capability.allow_client_incoming(user.username)
    capability.allow_client_outgoing(current_app.config['TWILIO_ACCOUNT_SID'])
    return capability.generate()
Exemple #5
0
 def authorize_user(self, request_data):
     facebook_provider = FacebookProvider()
     user_info = facebook_provider.get_user_info(request_data["access_token"])
     user_info["likes"] = facebook_provider.get_user_likes(request_data["access_token"])
     user_info["pictures"] = facebook_provider.get_user_profile_pictures(request_data["access_token"])
     user_info["friends"] = facebook_provider.get_user_friends(request_data["access_token"])
     db_user_info = db.tow.users.find_one({"facebook_id": user_info["facebook_id"]}, {"_id": 1})
     if db_user_info:
         user_info["date_modified"] = datetime.utcnow()
         db.tow.users.update({"facebook_id": user_info["facebook_id"]}, {"$set": user_info})
         user_info["_id"] = db_user_info["_id"]
     else:
         user_info["date_created"] = datetime.utcnow()
         user_info["date_modified"] = datetime.utcnow()
         user_info["_id"] = db.tow.users.insert(user_info)
     twilio_auth = TwilioCapability("AC28112a0d9703cebb067723c494f7afa1", "8a41f0807e4b022fd4357b2db4560bff")
     twilio_auth.allow_client_incoming(str(user_info["_id"]))
     twilio_auth.allow_client_outgoing("APc977ec85dc01e1d91c79331e2a22a9c6")
     twilio_token = twilio_auth.generate(60 * 60 * 24)
     result = \
         {
             "id": str(user_info["_id"]),
             "first_name": user_info["first_name"],
             "token": twilio_token,
             "is_active": True
         }
     return result
def start(client_name):
    twilio_capability = TwilioCapability(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
    twilio_capability.allow_client_incoming(client_name)

    capability_token = twilio_capability.generate()

    return render_template('client.html', capability_token=capability_token, client_name=client_name)
Exemple #7
0
def index(request):
    capability = TwilioCapability(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
    application_sid = "APabe7650f654fc34655fc81ae71caa3ff"
    capability.allow_client_outgoing(application_sid)
    capability.allow_client_incoming("jenny")
    token = capability.generate()
    print(token)
    return TemplateResponse(request, 'index.html', {'token': token})
Exemple #8
0
    def test_inbound_permissions(self):
        token = TwilioCapability("AC123", "XXXXX")
        token.allow_client_incoming("andy")
        payload = token.payload()

        eurl = "scope:client:incoming?clientName=andy"
        assert_equal(len(payload), 1)
        assert_equal(payload['scope'], eurl)
Exemple #9
0
    def test_inbound_permissions(self):
        token = TwilioCapability("AC123", "XXXXX")
        token.allow_client_incoming("andy")
        payload = token.payload()

        eurl = "scope:client:incoming?clientName=andy"
        assert_equal(len(payload), 1)
        assert_equal(payload['scope'], eurl)
Exemple #10
0
def client():
    """Respond to incoming requests"""
    client_name = request.values.get('client', None) or "jenny"
    capability = TwilioCapability(account_sid, auth_token)
    capability.allow_client_outgoing(application_sid)
    capability.allow_client_incoming(client_name)
    token = capability.generate()
    return render_template('client.html', token=token, client_name=client_name)
Exemple #11
0
 def get(self):
     capability = TwilioCapability(self.app.config.get('account_sid'), self.app.config.get('auth_token'))
     capability.allow_client_outgoing(self.app.config.get('application_sid'))
     capability.allow_client_incoming('agent1')
     token = capability.generate()
     params = {'token': token}
     jinja_env = self.app.config.get('template')
     template_environment = jinja_env('views').get_template('index.html')
     self.response.write(template_environment.render(params))
Exemple #12
0
def send_web_msg():

    capability = TwilioCapability(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
    capability.allow_client_incoming(default_client)
    capability.allow_client_outgoing(TWILIO_APP_SID)
    cap_token = capability.generate()
    print cap_token

    return render_template('send_web_msg.html', cap_token=cap_token, phone_number=default_number)
Exemple #13
0
def client():
    """Respond to incoming requests."""

    capability = TwilioCapability(account_sid, auth_token)
    capability.allow_client_outgoing(application_sid)
    capability.allow_client_incoming("tobias")
    token = capability.generate()

    return render_template('client.html', token=token)
Exemple #14
0
def test_client(request):
    capability = TwilioCapability(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN)
    capability.allow_client_outgoing(settings.TWILIO_APP_SID)
    capability.allow_client_incoming('test')
    token = capability.generate()

    return render(request, 'client.html', {
        'token': token
    })
Exemple #15
0
def index():
    # Create a capability token for this client instance
    capability = TwilioCapability(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
    # If the client attempts an outgoing call, invoke a TwiML app
    capability.allow_client_outgoing("AP17a745dc5cfc00000000000000000000")
    # We can make incoming calls to this client with <dial><client>david</client></dial>
    capability.allow_client_incoming("david")
    token = capability.generate()
    return render_template("client_browser.html",
                           capability_token=token)
Exemple #16
0
 def get(self, name):
     capability = TwilioCapability(TWILIO_CONFIG.account_sid, TWILIO_CONFIG.auth_token)
     number = self.rolodex.get_number(name)
     uniq_client_name = number
     capability.allow_client_incoming(uniq_client_name)
     self.render("phone.html",
             device_token=capability.generate(),
             pp_phone=util.pp_phone,
             name=name,
             number=number)
Exemple #17
0
 def get_twilio_token(self, user_info):
     twilio_auth = TwilioCapability("AC28112a0d9703cebb067723c494f7afa1", "8a41f0807e4b022fd4357b2db4560bff")
     twilio_auth.allow_client_incoming(user_info["id"])
     twilio_auth.allow_client_outgoing("APc977ec85dc01e1d91c79331e2a22a9c6")
     result = \
         {
             "token": twilio_auth.generate(60 * 60 * 24),
             "user_id": user_info["id"]
         }
     return result
Exemple #18
0
def index(request):
    account_sid = settings.TWILIO_ACCOUNT_SID
    auth_token = settings.TWILIO_AUTH_TOKEN
    application_sid = settings.TWILIO_APPLICATION_SID

    capability = TwilioCapability(account_sid, auth_token)
    capability.allow_client_outgoing(application_sid)
    capability.allow_client_incoming(request.user.username)
    twilio_token = capability.generate()
    return TemplateResponse(request, 'browser-phone.html', locals())
def index(request):
    account_sid = settings.TWILIO_ACCOUNT_SID
    auth_token = settings.TWILIO_AUTH_TOKEN
    application_sid = settings.TWILIO_APPLICATION_SID

    capability = TwilioCapability(account_sid, auth_token)
    capability.allow_client_outgoing(application_sid)
    capability.allow_client_incoming(request.user.username)
    twilio_token = capability.generate()
    return TemplateResponse(request, 'browser-phone.html', locals())
Exemple #20
0
    def get(self, *a, **kw):
        # Find these values at twilio.com/user/account
        account_sid = "ACd61a084824884699a1413e71f40a3b5a"
        auth_token = TWILIO_AUTH_TOKEN

        capability = TwilioCapability(account_sid, auth_token)
        capability.allow_client_outgoing('AP1812e773105345a397a849121138359a')
        capability.allow_client_incoming('test')
        token = capability.generate()

        self.render("templates/client.html", token=token)
def client():
    """Respond to incoming requests."""

    capability = TwilioCapability(ACCOUNT_SID, AUTH_TOKEN)
    application_sid = "APabe7650f654fc34655fc81ae71caa3ff"
    application_sid2 = "AP123"

    capability.allow_client_outgoing(application_sid2)
    capability.allow_client_incoming(default_client)

    token = capability.generate()
    return render_template('client.html', token=token, client_name=default_client)
Exemple #22
0
def client():
    configuration_error = None
    for key in ("TWILIO_ACCOUNT_SID", "TWILIO_AUTH_TOKEN", "TWILIO_APP_SID", "TWILIO_CALLER_ID"):
        if not app.config[key]:
            configuration_error = "Missing from local_settings.py: " "%s" % key
            token = None
    if not configuration_error:
        capability = TwilioCapability(app.config["TWILIO_ACCOUNT_SID"], app.config["TWILIO_AUTH_TOKEN"])
        capability.allow_client_incoming("joey_ramone")
        capability.allow_client_outgoing(app.config["TWILIO_APP_SID"])
        token = capability.generate()
    return render_template("client.html", token=token, configuration_error=configuration_error)
Exemple #23
0
def build_twilio_token(client_name):

    account_sid = 'AC9dbcad82b20275e6e1854351444f13c3'
    auth_token = 'd5eb94487e911314e5620b4ea18e6d74'

    capability = TwilioCapability(account_sid, auth_token)
    app_sid = 'AP4679912e15024febe5d6d1fc814e7c7d'

    capability.allow_client_outgoing(app_sid)
    capability.allow_client_incoming(client_name)

    return capability.generate()
def get_capability_token():
    """Respond to incoming requests."""

    # Find these values at twilio.com/console
    account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
    auth_token = 'your_auth_token'

    capability = TwilioCapability(account_sid, auth_token)

    capability.allow_client_incoming("jenny")
    token = capability.generate()

    return Response(token, mimetype='application/jwt')
def create_token(client_name):
	# get credentials for environment variables
	account_sid = 'ACf49e7e3210b0d62e18d0896c43faec2d'
	auth_token = 'cda8d559b05c77535967c816ce076b2c'
	
	capability = TwilioCapability(account_sid, auth_token)
	# app sid for TwiML app
	application_sid = app.config['TWILIO_APPLICATION_SID']
	
	capability.allow_client_outgoing(application_sid)
	capability.allow_client_incoming(client_name)

	return capability.generate()
Exemple #26
0
def build_twilio_token(client_name):

    # Find these values at twilio.com/user/account
    account_sid = "TWILIO_ACCOUNT_SID"
    auth_token = "TWILIO_AUTH_TOKEN"

    cap = TwilioCapability(account_sid, auth_token)

    app_sid = ''
    cap.allow_client_outgoing(app_sid)
    cap.allow_client_incoming(client_name)

    return cap.generate()
Exemple #27
0
def build_twilio_token(client_name):

    # Find these values at twilio.com/user/account
    account_sid = "TWILIO_ACCOUNT_SID"
    auth_token = "TWILIO_AUTH_TOKEN"

    cap = TwilioCapability(account_sid, auth_token)

    app_sid = ''
    cap.allow_client_outgoing(app_sid)
    cap.allow_client_incoming(client_name)

    return cap.generate()
Exemple #28
0
def token():
    # get credentials for environment variables

    # Generate a random user name
    identity = alphanumeric_only.sub('', fake.user_name())

    # Create a Capability Token
    capability = TwilioCapability(account_sid, auth_token)
    capability.allow_client_outgoing(application_sid)
    capability.allow_client_incoming(identity)
    token = capability.generate()

    # Return token info as JSON
    return jsonify(identity=identity, token=token)
Exemple #29
0
def client():
    """Respond to incoming requests."""

    # Find these values at twilio.com/user/account
    account_sid = "AC3d6188091a9109165c89ae83c5d94d1b"
    auth_token = "7a0007278ebe72b311ca4d476c7a6abc"

    capability = TwilioCapability(account_sid, auth_token)

    application_sid = "APcdc54402e77bd0aa98ab42bd5d045f89"  # Twilio Application Sid
    capability.allow_client_incoming("ram")
    token = capability.generate()

    return render_template('client.html', token=token)
Exemple #30
0
    def generate_token(self):
        sid_account = request.env.user.company_id.twilio_account_sid
        token_account = request.env.user.company_id.twilio_auth_token
        sid_twiml = request.env.user.company_id.twiml_application

        capability = TwilioCapability(sid_account, token_account)

        # Allow our users to make outgoing calls with Twilio Client
        capability.allow_client_outgoing(sid_twiml)
        capability.allow_client_incoming('support_agent')

        # Generate the capability token
        token = capability.generate()
        return token
Exemple #31
0
def client():
    """Respond to incoming requests."""

    # Find these values at twilio.com/user/account
    account_sid = "AC3d6188091a9109165c89ae83c5d94d1b"
    auth_token = "7a0007278ebe72b311ca4d476c7a6abc"

    capability = TwilioCapability(account_sid, auth_token)

    application_sid = "APcdc54402e77bd0aa98ab42bd5d045f89"  # Twilio Application Sid
    capability.allow_client_incoming("ram")
    token = capability.generate()

    return render_template("client.html", token=token)
Exemple #32
0
def client():
    """Respond to incoming requests."""

    # Find these values at twilio.com/user/account
    account_sid = "AC9c5adc79b9cf3d79fc46f47fa6165c1e"
    auth_token = "6c79f8833d77a2a0433db0418d33d0c7"

    capability = TwilioCapability(account_sid, auth_token)

    application_sid = "APaa7ff4fb5efb45971236e6762e90b1ba" # Twilio Application Sid
    capability.allow_client_outgoing(application_sid)
    capability.allow_client_incoming("jenny")
    token = capability.generate()

    return render_template('client.html', token=token)
Exemple #33
0
def client():
    """Respond to incoming requests."""

    # Find these values at twilio.com/user/account
    account_sid = "AC9c5adc79b9cf3d79fc46f47fa6165c1e"
    auth_token = "6c79f8833d77a2a0433db0418d33d0c7"

    capability = TwilioCapability(account_sid, auth_token)

    application_sid = "APaa7ff4fb5efb45971236e6762e90b1ba"  # Twilio Application Sid
    capability.allow_client_outgoing(application_sid)
    capability.allow_client_incoming("jenny")
    token = capability.generate()

    return render_template('client.html', token=token)
Exemple #34
0
def client():
    """Respond to incoming requests."""
 
    # Find these values at twilio.com/user/account
    account_sid = data["account_sid"] 
    auth_token = data["auth_token"] 
 
    capability = TwilioCapability(account_sid, auth_token)
 
    application_sid = data["application_sid"] # Twilio Application Sid
    capability.allow_client_outgoing(application_sid)
    capability.allow_client_incoming("jenny")
    token = capability.generate()
 
    return render_template('client.html', token=token)
Exemple #35
0
def get_token(request):
    """Returns a Twilio Client token.
    Create a TwilioCapability object with our Twilio API credentials."""
    capability = TwilioCapability(
        settings.TWILIO_ACCOUNT_SID,
        settings.TWILIO_AUTH_TOKEN)
    """Allow our users to make outgoing calls with Twilio Client"""
    capability.allow_client_outgoing(settings.TWIML_APPLICATION_SID)

    """Allow our users to accept incoming calls from pyphon"""
    capability.allow_client_incoming('caller')

    """Generate the capability token"""
    token = capability.generate()

    return JsonResponse({'token': token})
Exemple #36
0
    def test_decode(self):
        token = TwilioCapability("AC123", "XXXXX")
        token.allow_client_outgoing("AP123", foobar=3)
        token.allow_client_incoming("andy")
        token.allow_event_stream()

        outgoing_uri = "scope:client:outgoing?appParams=foobar%3D3&appSid=AP123&clientName=andy"
        incoming_uri = "scope:client:incoming?clientName=andy"
        event_uri = "scope:stream:subscribe?path=%2F2010-04-01%2FEvents"

        result = jwt.decode(token.generate(), "XXXXX")
        scope = result["scope"].split(" ")

        self.assertIn(outgoing_uri, scope)
        self.assertIn(incoming_uri, scope)
        self.assertIn(event_uri, scope)
Exemple #37
0
    def test_decode(self):
        token = TwilioCapability("AC123", "XXXXX")
        token.allow_client_outgoing("AP123", foobar=3)
        token.allow_client_incoming("andy")
        token.allow_event_stream()

        outgoing_uri = "scope:client:outgoing?appParams=foobar%3D3&appSid=AP123&clientName=andy"
        incoming_uri = "scope:client:incoming?clientName=andy"
        event_uri = "scope:stream:subscribe?path=%2F2010-04-01%2FEvents"

        result = jwt.decode(token.generate(), "XXXXX")
        scope = result["scope"].split(" ")

        self.assertIn(outgoing_uri, scope)
        self.assertIn(incoming_uri, scope)
        self.assertIn(event_uri, scope)
def client():
    configuration_error = None
    for key in ('TWILIO_ACCOUNT_SID', 'TWILIO_AUTH_TOKEN', 'TWILIO_APP_SID',
                'TWILIO_CALLER_ID'):
        if not app.config[key]:
            configuration_error = "Missing from local_settings.py: %s" % key
            token = None
    if not configuration_error:
        capability = TwilioCapability(app.config['TWILIO_ACCOUNT_SID'],
                                      app.config['TWILIO_AUTH_TOKEN'])
        capability.allow_client_incoming("joey_ramone")
        capability.allow_client_outgoing(app.config['TWILIO_APP_SID'])
        token = capability.generate()
    params = {'token': token}
    return render_template('client.html', params=params,
                           configuration_error=configuration_error)
def get_capability_token():
    """Respond to incoming requests."""

    # Find these values at twilio.com/console
    account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
    auth_token = 'your_auth_token'

    capability = TwilioCapability(account_sid, auth_token)

    # Twilio Application Sid
    application_sid = 'APXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
    capability.allow_client_outgoing(application_sid)
    capability.allow_client_incoming(request.form["ClientName"])
    token = capability.generate()

    return Response(token, mimetype='application/jwt')
Exemple #40
0
def client():
    """Respond to incoming requests."""
 
    account_sid = "AC566da319c49345fe4fbbbea81ada1de0"
    auth_token = "741080b04bcb6c2471cf9439d939abce"
 
    capability = TwilioCapability(account_sid, auth_token)

    # This is a special Quickstart application sid - or configure your own
    # at twilio.com/user/account/apps
    application_sid = "APabe7650f654fc34655fc81ae71caa3ff"
    capability.allow_client_outgoing(application_sid)
    capability.allow_client_incoming("JohnCorndog")
    token = capability.generate()
 
    return render_template('client.html', token=token)
Exemple #41
0
def incomingWidget(request):
    callsid = request.GET['callsid']
    group_id = request.GET['group_id']
    number = request.GET['number']
    account_sid = TWILIO_ACCOUNT_SID
    auth_token = TWILIO_AUTH_TOKEN
    capability = TwilioCapability(account_sid, auth_token)
    application_sid = APPLICATION_SID
    capability.allow_client_incoming(callsid)
    token = capability.generate()
    context_dict = {}
    context_dict['token'] = token
    context_dict['number'] = number
    context_dict['group_id'] = "g:" + group_id
    # TODO
    # change this to incoming call
    return render(request, 'incoming.html', context_dict)
Exemple #42
0
def token():
    account_sid = os.environ.get("ACCOUNT_SID", ACCOUNT_SID)
    auth_token = os.environ.get("AUTH_TOKEN", AUTH_TOKEN)
    app_sid = os.environ.get("APP_SID", APP_SID)

    capability = TwilioCapability(account_sid, auth_token)

    # This allows outgoing connections to TwiML application
    if request.values.get('allowOutgoing') != 'false':
        capability.allow_client_outgoing(app_sid)

    # This allows incoming connections to client (if specified)
    client = request.values.get('client')
    if client != None:
        capability.allow_client_incoming(client)

    # This returns a token to use with Twilio based on the account and capabilities defined above
    return capability.generate()
Exemple #43
0
def client():
    global pending_call_token
    token = request.args.get("token")

    print "/"
    print "pending_call_token: {}".format(pending_call_token)
    print "token: {}".format(token)

    if pending_call_token and (token == pending_call_token):
        capability = TwilioCapability(twilio_account_sid, twilio_auth_token)
        capability.allow_client_outgoing(twilio_application_sid)
        capability.allow_client_incoming(twilio_client_name)
        twilio_token = capability.generate()

        return render_template('client.html',
                               twilio_token=twilio_token,
                               call_token=pending_call_token,
                               door_unlock_digits=door_unlock_digits)
    else:
        return render_template("answered.html")
Exemple #44
0
def reqclient():
    """Respond to incoming requests."""

    client_name = request.values.get('client', None) or "jenny"

    # Find these values at twilio.com/user/account
    account_sid = __ACCOUNT_SID
    auth_token = __AUTH_TOKEN

    capability = TwilioCapability(account_sid, auth_token)

    application_sid = "APabe7650f654fc34655fc81ae71caa3ff"  # Twilio Application Sid
    capability.allow_client_outgoing(application_sid)
    capability.allow_client_incoming(client_name)
    token = capability.generate()

    return render_template('client.html',
                           token=token,
                           appID=__APP_ID,
                           appSecret=__APP_SECRET,
                           client_name=client_name)
Exemple #45
0
def get_token(request):
    """Returns a Twilio Client token"""
    # Create a TwilioCapability object with our Twilio API credentials
    capability = TwilioCapability(settings.TWILIO_ACCOUNT_SID,
                                  settings.TWILIO_AUTH_TOKEN)

    # Allow our users to make outgoing calls with Twilio Client
    capability.allow_client_outgoing(settings.TWIML_APPLICATION_SID)

    # If the user is on the support dashboard page, we allow them to accept
    # incoming calls to "support_agent"
    # (in a real app we would also require the user to be authenticated)
    if request.GET['forPage'] == reverse('dashboard'):
        capability.allow_client_incoming('support_agent')
    else:
        # Otherwise we give them a name of "customer"
        capability.allow_client_incoming('customer')

    # Generate the capability token
    token = capability.generate()

    return JsonResponse({'token': token})
Exemple #46
0
def generate(agent_id):
    account_sid = ENV['TWILIO_ACCOUNT_SID']
    auth_token = ENV['TWILIO_AUTH_TOKEN']
    capability = TwilioCapability(account_sid, auth_token)
    capability.allow_client_incoming(agent_id)
    return capability.generate()
Exemple #47
0
    def get(self):
      # force the user to login and get their user model
      user = self.current_user
      if user:
          login = ('%s (<a href="%s">sign out</a>)' % (user.nickname, users.create_logout_url("/")))
      else:
          self.response.out.write(self.user_login_page)
          return
       
      # check the site to determine if the site has been authorized. 
      # if so, look at the user model to see if they are the owner
      # if not, offer the user the ability to authorize the site (this should only happen once)
      capability = TwilioCapability(configuration.TWILIO_ACCOUNT_SID,configuration.TWILIO_AUTH_TOKEN)
      voicemail = []
      if user.activated is False:
          owner = db.GqlQuery("select * from User where activated = True").get()
          if owner is None:
              # start the owner verification sequence. 
              logging.debug('site verification started for %s' % user.nickname)
              code = randint(10000,99999)
              user.verification_code = str(code)
              user.put()
              sendSMS(configuration.SMS_VERIFICATION_PHONE,
                      'Enter this five digit code in the browser to validate your account %s' % str(code))
              template_file = 'templates/owner_verification.html'
          else:
              # this isn't the owner so they only get the one big button to 
              # call the owner of the phone
              template_file = 'templates/friend.html'
      else:
          # the owner of the site is both logged in and verified.
          # create a dialing interface for them to make outbound calls and
          # provide the capability to accept incoming calls.
          capability.allow_client_incoming("owner")
          logging.debug('the owner is logged in! now granted them incoming capabilities...')
          template_file = 'templates/owner.html'
          
          # find all of the user's voicemail
          vmail = db.GqlQuery("select * from Voicemail").fetch(10)
          for v in vmail:
              logging.debug('found voicemail %s' % v.create_date)
              message = {'date' : v.create_date,
                         'from' : v.from_number,
                         'duration' : v.voicemail_duration,
                         'url' : v.voicemail_url,
                        }
              voicemail.append(message)
              
      # now make sure the twilio configuration is correct
      if validateTwilio() is False:
        self.redirect('/error.html')
        return
      
      # generate the token based on the configured capabilities.
      # everyone can call out, but only the owner can accept incoming calls.
      capability.allow_client_outgoing(configuration.TWILIO_APP_SID)
      token = capability.generate()
 
      template_values = {'token':token,
                         'client':'owner',
                         'login':login,
                         'voicemail':voicemail,
                         'current_user':user.nickname,
                         'google_analytics':configuration.GOOGLE_ANALYTICS_CODE,
                         'name':configuration.MY_NAME,
                         'title':configuration.APP_TITLE,
                        }
      
      # generate the html
      path = os.path.join(os.path.dirname(__file__), template_file)
      self.response.out.write(template.render(path, template_values))