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 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(): 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 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 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)
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 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 voiceclient(): capability = TwilioCapability(account_sid, auth_token) capability.allow_client_outgoing(application_sid) token = capability.generate() return render_template('voiceclient.html', token=token)
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 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_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 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 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 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 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 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(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 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 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 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 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 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 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 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 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)
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 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')
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 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()
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 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 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 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(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 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 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)
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 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 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 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 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')
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 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')
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)