コード例 #1
0
ファイル: views.py プロジェクト: 4geeks/retosuas
def home(request):
    data = {}
    capability = TwilioCapability(twillio_account, twillio_token)
    capability.allow_client_outgoing(twillio_sid)
    data["token"] = capability.generate()

    return render_to_response("home.html", data)
コード例 #2
0
ファイル: app.py プロジェクト: dinalamdany/instagramophone
def generate_token():
    capability = TwilioCapability(account_sid, auth_token)
    capability.allow_client_outgoing(application_sid)
    test = capability.generate()
    print(test)
    #return capaddbility.generate()
    return test
コード例 #3
0
ファイル: phonewtf.py プロジェクト: nickgirardo/PhoneWtf
def index():
    braintree_token = client_token()
     
    capability = TwilioCapability(config.twilio['account_sid'], config.twilio['auth_token'])
    capability.allow_client_outgoing(config.twilio['app_sid'])
    twilio_token = capability.generate()
    return render_template('index.jade', title="Phone WTF", twilio_token=twilio_token)
コード例 #4
0
ファイル: views.py プロジェクト: robboyle/asesor
def question_translator(request, question):
    if question.translator and not question.translator == request.user:
        return HttpResponseRedirect(reverse('dashboard'))
    
    if request.method == "POST":
        if 'set_translator' in request.POST:
            question.translator = request.user
        if 'translation' in request.POST:
            question.translation = request.POST['translation']
        if 'is_translated' in request.POST:
            question.is_translated = request.POST['is_translated']
        if 'is_calledback' in request.POST:
            question.is_calledback = request.POST['is_calledback']
         
        question.save()   
            
        if ('is_calledback' in request.POST and question.is_calledback) or ('is_translated' in request.POST and question.is_translated):
            return HttpResponseRedirect(reverse('dashboard'))
    
    if question.is_translated:
        from twilio.util import TwilioCapability
        
        capability = TwilioCapability(settings.TWILIO_ACCT_SID, settings.TWILIO_AUTH_TOKEN)
        capability.allow_client_outgoing(settings.TWILIO_OUTGOING_APP_ID)        
        capability_token = capability.generate()
    else:
        capability_token = ''
            
    return render_to_response('question_translator.html', {
                                        'question': question,
                                        'capability_token': capability_token,
                                    }, context_instance=RequestContext(request))
コード例 #5
0
def index():
    reason = reasonSonyaIsAwesome()
    capability = TwilioCapability(app.config['ACCOUNT_SID'],
        app.config['AUTH_TOKEN'])
    capability.allow_client_outgoing(app.config['SONYA_APP_SID'])
    token = capability.generate()
    return render_template('index.html', token=token, reason=reason)
コード例 #6
0
ファイル: pusher2talk.py プロジェクト: Rumyra/pusher2talk
	def clienttoken(self, var=None, **params):
		clientid = urllib.unquote(cherrypy.request.params['clientid'])
		room = clientid.split(".")[0]
		user = clientid.split(".")[1]
		capability = TwilioCapability(account, token)
		capability.allow_client_outgoing(application_sid)
		return capability.generate()
コード例 #7
0
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)
コード例 #8
0
ファイル: auth_provider.py プロジェクト: xoperator/ToW
 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
コード例 #9
0
def generate_token():
    capability = TwilioCapability(account_sid, auth_token)
    capability.allow_client_outgoing(application_sid)
    test = capability.generate()
    print(test)
    #return capaddbility.generate()
    return test
コード例 #10
0
ファイル: app.py プロジェクト: mikekrieger/BSS_SMS_QuoteBot
def index():
    reason = quotes()
    capability = TwilioCapability(app.config['ACCOUNT_SID'],
                                  app.config['AUTH_TOKEN'])
    capability.allow_client_outgoing(app.config['BSSSPAM_APP_SID'])
    token = capability.generate()
    return render_template('index.html', token=token, reason=reason)
コード例 #11
0
 def clienttoken(self, var=None, **params):
     clientid = urllib.unquote(cherrypy.request.params['clientid'])
     room = clientid.split(".")[0]
     user = clientid.split(".")[1]
     capability = TwilioCapability(account, token)
     capability.allow_client_outgoing(application_sid)
     return capability.generate()
コード例 #12
0
ファイル: run.py プロジェクト: gholadr/twilio-prototype
def voiceclient():

    capability = TwilioCapability(account_sid, auth_token)
    capability.allow_client_outgoing(application_sid)
    token = capability.generate()
 
    return render_template('voiceclient.html', token=token)
コード例 #13
0
ファイル: app.py プロジェクト: aurofable/medhack-server
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)
コード例 #14
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')
    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()
コード例 #15
0
ファイル: views.py プロジェクト: kevana/phonedusk-server
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()
コード例 #16
0
def get_twilio_token():
	user = ensureLogin(None)
	if(user == None):
		return {'result':'Failure', 'message':'Unauthenticated'}
	
	# from trial account of [email protected]
	# account_sid = "AC3c6446cabf093a6d43eb5743bb067734"
	# auth_token = "81ce4d34613c2d8cc6c4492abc01fa14"
	# application_sid = "AP1f6c103b3e8f4db78b85d6b6c78a10c4"
	# application_sid = "AP2dc65dfde4f16248498ade72fa759cc9"

	# from real account of [email protected]
	# account_sid = "ACd7492f73100e1169b076b734253b85d9"
	# auth_token = "e52b5cca6cc4295337838ac9fcb13421"

	account_sid = hmpconstants.TwilioSetup.account_sid
	auth_token = hmpconstants.TwilioSetup.auth_token
 
	# This is a special Quickstart application sid - or configure your own
	# at twilio.com/user/account/apps

	# application_sid pointing to manoj's local dev
	# application_sid = "AP6cf341f0c8d65f51cb7a908ae944cbf1"

	# application_sid pointing to remedysquare prod
	# application_sid = "APcc1d73bf14b7f0b998a0f86a96a8e552"

	application_sid = hmpconstants.TwilioSetup.application_sid
	
	
 
	capability = TwilioCapability(account_sid, auth_token)
	capability.allow_client_outgoing(application_sid)
	token = capability.generate()
	return {'result':'Success', 'message':token,'token':token} 
コード例 #17
0
ファイル: app.py プロジェクト: zamzam2121/Prank-Roulette
def main_page():
    """Respond to incoming requests."""
    capability = TwilioCapability(account_sid, auth_token)

    capability.allow_client_outgoing(application_sid)
    token = capability.generate()

    return render_template('index.html', token=token)
コード例 #18
0
def index(name="Somebody Put Something In My Ring"):
    # Generate Twilio client token
    capability = TwilioCapability(app.config['ACCOUNT_SID'],
                                  app.config['AUTH_TOKEN'])
    capability.allow_client_outgoing(app.config['RAMONES_APP_SID'])
    token = capability.generate()

    return render_template('index.html', name=name, token=token)
コード例 #19
0
ファイル: views.py プロジェクト: ecaminero/TwilioTesting
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})
コード例 #20
0
def index(name="Somebody Put Something In My Ring"):
    # Generate Twilio client token
    capability = TwilioCapability(app.config['ACCOUNT_SID'],
        app.config['AUTH_TOKEN'])
    capability.allow_client_outgoing(app.config['RAMONES_APP_SID'])
    token = capability.generate()

    return render_template('index.html', name=name, token=token)
コード例 #21
0
ファイル: hello_monkey.py プロジェクト: gddk/twilio_tut
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)
コード例 #22
0
ファイル: views.py プロジェクト: xealot/vocalbroker
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
    })
コード例 #23
0
ファイル: app.py プロジェクト: nyghtowl/Twilio_Workshop
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)
コード例 #24
0
ファイル: pusher2talk.py プロジェクト: Rumyra/pusher2talk
	def test(self, var=None, **params):
		room = str(urllib.unquote(cherrypy.request.params['room']))
		user = str(urllib.unquote(cherrypy.request.params['user']))
		capability = TwilioCapability(account, token)
		capability.allow_client_outgoing(application_sid)
		template_values = {"token": capability.generate(), "room" : room, "user": user}
		t = loader.get_template('test.html')
		c = Context(template_values)
		return t.render(c)
コード例 #25
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))
コード例 #26
0
def generate_token(account_sid, auth_token, application_sid):
    """
    Create a capability token given Twilio account credentials
    and an application sid.
    """
    capability = TwilioCapability(account_sid, auth_token)
    # Allow access to the Call-in ApplicationSid we created
    capability.allow_client_outgoing(application_sid)
    return capability.generate()
コード例 #27
0
ファイル: visitor.py プロジェクト: davitv/listin
 def get_context_data(self, **kwargs):
     context = super(TwillioView, self).get_context_data(**kwargs)
     context['account_sid'] = settings.TWILLIO_ACCOUNT_SID
     context['auth_token'] = settings.TWILLIO_AUTH_TOKEN
     context['auth_token'] = settings.TWILLIO_APP_SID
     capability = TwilioCapability(settings.TWILLIO_ACCOUNT_SID,
                                   settings.TWILLIO_AUTH_TOKEN)
     capability.allow_client_outgoing(settings.TWILLIO_APP_SID)
     context['token'] = capability.generate()
     return context
コード例 #28
0
def client(request):
    account_sid = TWILIO_ACCOUNT_SID
    auth_token = TWILIO_AUTH_TOKEN
    capability = TwilioCapability(account_sid, auth_token)
    application_sid = APPLICATION_SID
    capability.allow_client_outgoing(application_sid)
    token = capability.generate()
    context_dict = {}
    context_dict['token'] = token
    return render(request, 'client.html', context_dict)
コード例 #29
0
ファイル: views.py プロジェクト: mmahnken/Twilio-Tutorial
def client():
	"""Respond to incoming requests"""
	account_sid = 'AC324fcac164de8fa3e412a7747c1bb884'
	auth_token = '8018f62a5ce49f4399f5855e9ab53f0f'
	application_sid = "APabe7650f654fc34655fc81ae71caa3ff"
	"""Generate the secure capability token"""
	capability = TwilioCapability(account_sid, auth_token)
	capability.allow_client_outgoing(application_sid)
	token = capability.generate()
	return render_template('client.html', token = token)
コード例 #30
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())
コード例 #31
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())
コード例 #32
0
ファイル: auth_provider.py プロジェクト: xoperator/ToW
 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
コード例 #33
0
ファイル: pusher2talk.py プロジェクト: Rumyra/pusher2talk
	def main(self, var=None, **params):
		clientid = urllib.unquote(cherrypy.request.params['id'])
		room = clientid.split(".")[0]
		user = clientid.split(".")[1]
		capability = TwilioCapability(account, token)
		capability.allow_client_outgoing(application_sid)
		template_values = {"token": capability.generate(), "room" : room, "user": user}
		t = loader.get_template('mainclient.html')
		c = Context(template_values)
		return t.render(c)
コード例 #34
0
ファイル: app.py プロジェクト: davidpickavance/client_agent
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)
コード例 #35
0
ファイル: softphone.py プロジェクト: ojengwa/phonio
 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)
コード例 #36
0
def index():
    reason, source = reasonSonyaIsAwesome().split('::')
    capability = TwilioCapability(app.config['ACCOUNT_SID'],
                                  app.config['AUTH_TOKEN'])
    capability.allow_client_outgoing(app.config['SONYA_APP_SID'])
    token = capability.generate()
    return render_template('index.html',
                           token=token,
                           reason=reason,
                           source=source)
コード例 #37
0
ファイル: app.py プロジェクト: eanderle/trytwilio
def getPage(page):
  if page in lessons:
    capability = TwilioCapability(ACCOUNT_SID, AUTH_TOKEN)
    capability.allow_client_outgoing(APP_SID)
    token = capability.generate()
    params = {
      'token':token
    }
    return render_template(page + '.html', params=params)
  else:
    return render_template('notFound.html')
コード例 #38
0
ファイル: alpha.py プロジェクト: xealot/vocalbroker
    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)
コード例 #39
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

    print(capability.generate())
    return capability.generate()
コード例 #40
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()
コード例 #41
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()
コード例 #42
0
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')
コード例 #43
0
 def test(self, var=None, **params):
     room = str(urllib.unquote(cherrypy.request.params['room']))
     user = str(urllib.unquote(cherrypy.request.params['user']))
     capability = TwilioCapability(account, token)
     capability.allow_client_outgoing(application_sid)
     template_values = {
         "token": capability.generate(),
         "room": room,
         "user": user
     }
     t = loader.get_template('test.html')
     c = Context(template_values)
     return t.render(c)
コード例 #44
0
 def main(self, var=None, **params):
     clientid = urllib.unquote(cherrypy.request.params['id'])
     room = clientid.split(".")[0]
     user = clientid.split(".")[1]
     capability = TwilioCapability(account, token)
     capability.allow_client_outgoing(application_sid)
     template_values = {
         "token": capability.generate(),
         "room": room,
         "user": user
     }
     t = loader.get_template('mainclient.html')
     c = Context(template_values)
     return t.render(c)
コード例 #45
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)
コード例 #46
0
ファイル: run.py プロジェクト: ramanala/740-project
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)
コード例 #47
0
ファイル: main.py プロジェクト: vidtsin/odoo-twilio
    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
コード例 #48
0
def main_page():
    """Respond to incoming requests."""
    account_sid = ""
    auth_token = ""

    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 = "APaf6c7ab08a32e7fb541a78d97d592100"
    capability.allow_client_outgoing(application_sid)
    token = capability.generate()

    return render_template('index.html', token=token)
コード例 #49
0
def client():
    """Respond to incoming requests."""
 
    account_sid = "ACdfd86ae9d14d1932491fb8d18c1bc983"
    auth_token = "31999b4fabf7b98ba4491738c9b4c493"
 
    # This is a special Quickstart application sid - or configure your own
    # at twilio.com/user/account/apps
    application_sid = "APabe7650f654fc34655fc81ae71caa3ff"
 
    capability = TwilioCapability(account_sid, auth_token)
    capability.allow_client_outgoing(application_sid)
    token = capability.generate()
 
    return render_template('client.html', token=token)
コード例 #50
0
    def dispatch(self, request, *args, **kwargs):
        account_sid = settings.TWILIO_ACCOUNT_SID
        auth_token = settings.TWILIO_AUTH_TOKEN
        application_sid = settings.TWILIO_CALLBACK_APP_SID

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

        manager = request.user.callbackmanager

        return JsonResponse({
            'token': token,
            'manager': Signer().sign(manager.pk)
        })
コード例 #51
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)
コード例 #52
0
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')
コード例 #53
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()
    params = {'token': token}
    return render_template('client.html', params=params,
                           configuration_error=configuration_error)
コード例 #54
0
def capability_token(request):
    mhluser_id = request.user.id
    capability = TwilioCapability(settings.TWILIO_ACCOUNT_SID,
                                  settings.TWILIO_ACCOUNT_TOKEN)
    capability.allow_client_outgoing(settings.TWILIO_APP_SID)
    capabilityToken = capability.generate()
    response = {
        'data': {
            'capabilityToken': capabilityToken,
            'mhluser_id': mhluser_id
        },
        'warnings': {},
    }
    print json.dumps(response)
    return HttpResponse(content=json.dumps(response),
                        mimetype='application/json')
コード例 #55
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)