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)
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 audio(campaign_id): campaign = Campaign.query.filter_by(id=campaign_id).first_or_404() form = CampaignAudioForm() twilio_client = current_app.config.get("TWILIO_CLIENT") twilio_capability = TwilioCapability(*twilio_client.auth) twilio_capability.allow_client_outgoing(current_app.config.get("TWILIO_PLAYBACK_APP")) for field in form: campaign_audio, is_default_message = campaign.audio_or_default(field.name) if not is_default_message: field.data = campaign_audio if form.validate_on_submit(): form.populate_obj(campaign) db.session.add(campaign) db.session.commit() flash("Campaign audio updated.", "success") return redirect(url_for("campaign.launch", campaign_id=campaign.id)) return render_template( "campaign/audio.html", campaign=campaign, form=form, twilio_capability=twilio_capability, descriptions=current_app.config.CAMPAIGN_FIELD_DESCRIPTIONS, example_text=current_app.config.CAMPAIGN_MESSAGE_DEFAULTS, )
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()
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()
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}
def test_outbound_permissions_params(self): token = TwilioCapability("AC123", "XXXXX") token.allow_client_outgoing("AP123", foobar=3) payload = token.payload() eurl = "scope:client:outgoing?appParams=foobar%3D3&appSid=AP123" assert_equal(payload["scope"], eurl)
def audio(campaign_id): campaign = Campaign.query.filter_by(id=campaign_id).first_or_404() form = CampaignAudioForm() twilio_client = current_app.config.get('TWILIO_CLIENT') twilio_capability = TwilioCapability(*twilio_client.auth) twilio_capability.allow_client_outgoing(current_app.config.get('TWILIO_PLAYBACK_APP')) for field in form: campaign_audio, is_default_message = campaign.audio_or_default(field.name) if not is_default_message: field.data = campaign_audio if form.validate_on_submit(): form.populate_obj(campaign) db.session.add(campaign) db.session.commit() flash('Campaign audio updated.', 'success') return redirect(url_for('campaign.launch', campaign_id=campaign.id)) return render_template('campaign/audio.html', campaign=campaign, form=form, twilio_capability = twilio_capability, descriptions=current_app.config.CAMPAIGN_FIELD_DESCRIPTIONS, example_text=current_app.config.CAMPAIGN_MESSAGE_DEFAULTS)
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)
def voiceclient(): capability = TwilioCapability(account_sid, auth_token) capability.allow_client_outgoing(application_sid) token = capability.generate() return render_template('voiceclient.html', token=token)
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()
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))
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)
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()
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
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
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)
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)
def test_outbound_permissions_params(self): token = TwilioCapability("AC123", "XXXXX") token.allow_client_outgoing("AP123", foobar=3) payload = token.payload() eurl = "scope:client:outgoing?appParams=foobar%3D3&appSid=AP123" assert_equal(payload["scope"], eurl)
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)
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)
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)
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})
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)
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)
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 })
def task_profile(request, task_id): task = get_object_or_404(Task, id = task_id) #It wasn't bad enough that the actual create form was wet and silly. Now this too. TODO: FIX THIS F****R. user_can_make_new_prototypes = True #TODO: Turn this into an actual privilege assessment task_prototype_name_form = TaskPrototypeNameForm() task_prototype_name_form.fields['name'].widget.attrs['class'] = "topLevel" #So that we can recognize it later via autocomplete. rest_of_the_task_prototype_form = RestOfTheTaskPrototypeForm() user_privileges = get_privileges_for_user(request.user) #Wet and silly. TODO: Fix class SimpleChildForm(forms.Form): child = AutoCompleteField(models = (TaskPrototype,), name_visible_field=True) class SimpleParentForm(forms.Form): parent = AutoCompleteField(models = (TaskPrototype,), name_visible_field=True) task_prototype_form = TaskPrototypeForm() task_prototype_parent_form = SimpleParentForm() task_prototype_child_form = SimpleChildForm() draw_attention_ajax_form = DrawAttentionAjaxForm() if task.prototype.id == 251 or task.prototype.id == 7: has_outgoing_call = True disable_incoming_calls = True account_sid = "AC260e405c96ce1eddffbddeee43a13004" auth_token = "fd219130e257e25e78613adc6c003d1a" capability = TwilioCapability(account_sid, auth_token) capability.allow_client_outgoing("APd13a42e60c91095f3b8683a77ee2dd05") #The text of the call recipient will be the name of the person in the case of a tech job. It will be the output of the unicode method of the PhoneNumber in the case of a PhoneCall resolution. if task.prototype.id == 251: call_to_name = task.related_objects.all()[0].object.get_full_name() related_user = task.related_objects.all()[0].object phone_numbers = task.related_objects.all()[0].object.userprofile.contact_info.phone_numbers.all() if task.prototype.id == 7: phone_numbers = [task.related_objects.all()[0].object.from_number] if task.related_objects.all()[0].object.from_number.owner: call_to_name = task.related_objects.all()[0].object.from_number.owner else: call_to_name = "Phone Number #%s" % (str(task.related_objects.all()[0].object.id)) return render(request, 'do/task_profile.html', locals() )
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()
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)
def test_outbound_permissions(self): token = TwilioCapability("AC123", "XXXXX") token.allow_client_outgoing("AP123") payload = token.payload() eurl = "scope:client:outgoing?appSid=AP123" assert_equal(len(payload), 1) self.assertIn(eurl, payload['scope'])
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))
def test_outbound_permissions(self): token = TwilioCapability("AC123", "XXXXX") token.allow_client_outgoing("AP123") payload = token.payload() eurl = "scope:client:outgoing?appSid=AP123" assert_equal(len(payload), 1) self.assertIn(eurl, payload['scope'])
def task_profile(request, task_id): task = get_object_or_404(Task, id=task_id) #It wasn't bad enough that the actual create form was wet and silly. Now this too. TODO: FIX THIS F****R. user_can_make_new_prototypes = True #TODO: Turn this into an actual privilege assessment task_prototype_name_form = TaskPrototypeNameForm() task_prototype_name_form.fields['name'].widget.attrs[ 'class'] = "topLevel" #So that we can recognize it later via autocomplete. rest_of_the_task_prototype_form = RestOfTheTaskPrototypeForm() user_privileges = get_privileges_for_user(request.user) #Wet and silly. TODO: Fix class SimpleChildForm(forms.Form): child = AutoCompleteField(models=(TaskPrototype, ), name_visible_field=True) class SimpleParentForm(forms.Form): parent = AutoCompleteField(models=(TaskPrototype, ), name_visible_field=True) task_prototype_form = TaskPrototypeForm() task_prototype_parent_form = SimpleParentForm() task_prototype_child_form = SimpleChildForm() draw_attention_ajax_form = DrawAttentionAjaxForm() if task.prototype.id == 251 or task.prototype.id == 7: has_outgoing_call = True disable_incoming_calls = True account_sid = "AC260e405c96ce1eddffbddeee43a13004" auth_token = "fd219130e257e25e78613adc6c003d1a" capability = TwilioCapability(account_sid, auth_token) capability.allow_client_outgoing("APd13a42e60c91095f3b8683a77ee2dd05") #The text of the call recipient will be the name of the person in the case of a tech job. It will be the output of the unicode method of the PhoneNumber in the case of a PhoneCall resolution. if task.prototype.id == 251: call_to_name = task.related_objects.all()[0].object.get_full_name() related_user = task.related_objects.all()[0].object phone_numbers = task.related_objects.all( )[0].object.userprofile.contact_info.phone_numbers.all() if task.prototype.id == 7: phone_numbers = [task.related_objects.all()[0].object.from_number] if task.related_objects.all()[0].object.from_number.owner: call_to_name = task.related_objects.all( )[0].object.from_number.owner else: call_to_name = "Phone Number #%s" % (str( task.related_objects.all()[0].object.id)) return render(request, 'do/task_profile.html', locals())
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)
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)
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)
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())
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
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
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)
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)
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 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()
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)
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)
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
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_outgoing(application_sid) token = capability.generate() return render_template('client.html', token=token)
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)
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)
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)
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) token = capability.generate() return Response(token, mimetype='application/jwt')
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) })
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)
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')