Example #1
0
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)
Example #2
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())
Example #3
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
Example #4
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
Example #5
0
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)
Example #6
0
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)
Example #7
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()
Example #8
0
    def test_events(self):
        token = TwilioCapability("AC123", "XXXXX")
        token.allow_event_stream()
        payload = token.payload()

        event_uri = "scope:stream:subscribe?path=%2F2010-04-01%2FEvents"
        assert_equal(payload["scope"], event_uri)
Example #9
0
    def test_events(self):
        token = TwilioCapability("AC123", "XXXXX")
        token.allow_event_stream()
        payload = token.payload()

        event_uri = "scope:stream:subscribe?path=%2F2010-04-01%2FEvents"
        assert_equal(payload["scope"], event_uri)
Example #10
0
    def test_events_with_filters(self):
        token = TwilioCapability("AC123", "XXXXX")
        token.allow_event_stream(foobar="hey")
        payload = token.payload()

        event_uri = "scope:stream:subscribe?params=foobar%3Dhey&path=%2F2010-04-01%2FEvents"
        assert_equal(payload["scope"], event_uri)
Example #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()
Example #12
0
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,
    )
Example #13
0
    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)
Example #14
0
    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)
Example #15
0
    def test_events_with_filters(self):
        token = TwilioCapability("AC123", "XXXXX")
        token.allow_event_stream(foobar="hey")
        payload = token.payload()

        event_uri = "scope:stream:subscribe?params=foobar%3Dhey&path=%2F2010-04-01%2FEvents"
        assert_equal(payload["scope"], event_uri)
Example #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} 
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)
Example #18
0
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))
Example #19
0
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 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)
Example #21
0
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 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)
Example #23
0
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)
Example #24
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)
Example #25
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)
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)
Example #27
0
    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'])
Example #28
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()
Example #29
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)
Example #30
0
    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'])
Example #31
0
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() 
                  )
Example #32
0
File: views.py Project: jMyles/WHAT
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())
Example #33
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)
Example #34
0
 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
Example #35
0
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)
Example #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)
Example #37
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)
Example #38
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)
Example #39
0
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')
Example #40
0
def generate_token():
    ACCOUNT_SID = settings.ACCOUNT_SID
    AUTH_TOKEN = settings.AUTH_TOKEN

    client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
    apps = client.applications.list()
    application = apps[0]
    sid = application.sid

    capability = TwilioCapability(ACCOUNT_SID, AUTH_TOKEN)
    capability.allow_client_outgoing(sid)
    return capability.generate()
Example #41
0
def main():
    account_sid = os.environ.get('TWILIO_ACCOUNT_SID')
    auth_token = os.environ.get('TWILIO_AUTH_TOKEN')

    # This is a special Quickstart application sid - or configure your own
    # at twilio.com/user/account/apps
    application_sid = os.environ.get('TWILIO_APP_SID')

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

    return render_template('index.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)

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

    return Response(token, mimetype='application/jwt')
Example #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)
Example #44
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)
Example #45
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)
Example #46
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)
Example #47
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)
Example #48
0
def main_page():
    """Respond to incoming requests."""
    account_sid = os.environ.get("ACCOUNT_SID")
    auth_token = os.environ.get("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 = os.environ.get("APP_SID")
    capability.allow_client_outgoing(application_sid)
    token = capability.generate()

    return render_template('index.html', token=token)
Example #49
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)
        })
Example #50
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)
Example #51
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')
Example #52
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)
Example #53
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)
Example #54
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)
Example #55
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))