def token(): # Get credentials for environment variables account_sid = 'ACbce0865b277c75152da6fc469b650463' api_key = 'SK2e4b45c9cb8835c6ad1a614c3346b209' api_secret = 'l6GKan4KkOKCmiktZDTmhahRY7q2aTPz' # Create an Access Token token = AccessToken(account_sid, api_key, api_secret) # Set the Identity of this token token.identity = request.values.get('identity') or 'identity' # Grant access to Video grant = VideoGrant() grant.room = request.values.get('room') token.add_grant(grant) # Return token return token.to_jwt()
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 = request.values.get('identity') or 'identity' # Grant access to Video grant = VideoGrant() grant.room = request.values.get('room') token.add_grant(grant) # Return token return token.to_jwt()
def token(): # Get credentials for environment variables account_sid = "ACa9489e89bea2fd6a143b64def1cf01f7" api_key = "SKe3a14561d59837544e4079f95e9b6616" api_secret = "4mxMGKNUjD80RhIZ1xGxtaP6ABCnIlUD" # Create an Access Token token = AccessToken(account_sid, api_key, api_secret) # Set the Identity of this token token.identity = request.values.get('identity') or 'identity' # Grant access to Video grant = VideoGrant() grant.room = request.values.get('room') token.add_grant(grant) # Return token return token.to_jwt()
def token(room_name): # get credentials for environment variables account_sid = os.getenv("TWILIO_ACCOUNT_SID") api_key = os.getenv("TWILIO_API_KEY") api_secret = os.getenv("TWILIO_API_SECRET") # Create an Access Token token = AccessToken(account_sid, api_key, api_secret) # Set the Identity of this token print(_request_ctx_stack.top.current_user['sub']) token.identity = _request_ctx_stack.top.current_user['sub'] # Grant access to Video grant = VideoGrant() grant.room = room_name token.add_grant(grant) # Return token info as JSON return jsonify(identity=token.identity, token=token.to_jwt().decode('UTF-8'))
def get_token(identity, room): # 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 time_stamp = time.time() token.identity = identity + str(time_stamp) # Grant access to Video grant = VideoGrant() grant.room = room token.add_grant(grant) # Return token return token.to_jwt().decode('utf-8')
def token(request): # Create an Access Token token = AccessToken(ACCOUNT_SID, API_KEY, API_SECRET) # Set the Identity of this token # token.identity = request.values.get('identity') or 'identity' token.identity = fake.name() # Grant access to Video grant = VideoGrant() # grant.room = requests.get('room') grant.room = 'room' token.add_grant(grant) # Return token # return token.to_jwt() data = { 'identity': token.identity, 'token': token.to_jwt().decode('utf-8') } return Response(data, status=HTTP_200_OK)