def new_twilio_video_tokens(): # get credentials from config account_sid = 'AC6fbff77992d10662d2d14d9facc494c3' # live_config('TWILIO_ACCOUNT_SID') api_key = 'SK66c0077df076e009565295cd006c0925' #live_config('TWILIO_API_KEY') api_secret = '73w1nYUgPH0sI2KZtgp7qFlSGDGjgn8n' #live_config('TWILIO_API_SECRET') profile_id = 'VSace2c5699219999e4edfcd4b94d7be85' #live_config('TWILIO_CONFIGURATION_SID') id_patient = str(uuid4()) id_clinician = str(uuid4()) # Create an Access Tokens token_patient = AccessToken(account_sid, api_key, api_secret) token_patient.identity = id_patient token_clinician = AccessToken(account_sid, api_key, api_secret) token_clinician.identity = id_clinician # Grant access to Conversations grant = ConversationsGrant() grant.configuration_profile_sid = profile_id token_patient.add_grant(grant) token_clinician.add_grant(grant) # Return token info # we will use the same fields as opentok assuming we will have # only one video provider for a given consult. return { # patient will make the connection so we only keep the clinician id. 'twilio_video_id_clinician': token_clinician.identity, 'twilio_video_token_clinician': token_clinician.to_jwt(), 'twilio_video_id_patient': token_patient.identity, 'twilio_video_token_patient': token_patient.to_jwt(), 'video_provider': 'twilio', }
def get_accesstoken(self): """ # This function builds jwt of access token with username """ # Select sid from t1, according userid and classid sid = self.check_access() # Select authtoken, apikey, secret fro table t0. infoacc = Subaccount.query.filter_by(id=sid).all() users = Users.query.filter_by(id=self.userid).all() # Substitute your Twilio AccountSid and ApiKey details ACCOUNT_SID = sid API_KEY_SID = infoacc[0].apikey API_KEY_SECRET = infoacc[0].apisecret CONFIGURATION_SID = infoacc[0].configid # Create an Access Token token = AccessToken(ACCOUNT_SID, API_KEY_SID, API_KEY_SECRET) # Set the Identity of this token username = users[0].name token.identity = username # Grant access to Conversations grant = ConversationsGrant() grant.configuration_profile_sid = CONFIGURATION_SID token.add_grant(grant) # Return token info as JSON return token
def token(): # get credentials for environment variables account_sid = os.environ['TWILIO_ACCOUNT_SID'] api_key = os.environ['TWILIO_API_KEY'] api_secret = os.environ['TWILIO_API_SECRET'] # Create an Access Token token = AccessToken(account_sid, api_key, api_secret) # Set the Identity of this token token.identity = fake.user_name() # Grant access to Conversations grant = ConversationsGrant() grant.configuration_profile_sid = os.environ['TWILIO_CONFIGURATION_SID'] token.add_grant(grant) # Return token info as JSON return jsonify(identity=token.identity, token=token.to_jwt())
def token(): # get credentials for environment variables account_sid = 'ACd9b72d3e2fd1c7afee885f62d2d95a95' api_key = 'SK3a1be8585f189c540584a1757e10ba69' api_secret = 'aNovO6gcHsTOUjByHkUruUHyhq1Aserx' # Create an Access Token token = AccessToken(account_sid, api_key, api_secret) # Set the Identity of this token token.identity = session[secret] # Grant access to Video grant = VideoGrant() grant.configuration_profile_sid = 'VSa37a06ac2dac126260d6675aae39566f' token.add_grant(grant) # Return token info as JSON return jsonify(identity=token.identity, token=token.to_jwt())
def get_token(request): account_sid = os.environ['TWILIO_ACCOUNT_SID'] api_key = os.environ['TWILIO_API_KEY'] api_secret = os.environ['TWILIO_API_SECRET'] # Create an Access Token token = AccessToken(account_sid, api_key, api_secret) # Set the Identity of this token random_names = [ "Christian Blatter", "Tanaz Kesariwala", "Shanaya Kapoor", "Alisha Chauhan" ] token.identity = random.choice(random_names) # Grant access to Conversations # grant = ConversationsGrant() # grant.configuration_profile_sid = os.environ['TWILIO_CONFIGURATION_SID'] # token.add_grant(grant) # Return token info as JSON return JsonResponse({"identity": token.identity, "token": token.to_jwt()})