in Python/Encrypt credentials/Encryption sample/utils.py [0:0]
def validate_config(app):
''' Returns a message to user for missing configuration
Args:
app (Flask): Flask app object
Returns:
string: Error info
'''
authenticate_mode = app.config['AUTHENTICATION_MODE']
tenant_id = app.config['TENANT_ID']
client_id = app.config['CLIENT_ID']
username = app.config['POWER_BI_USER']
password = app.config['POWER_BI_PASS']
client_secret = app.config['CLIENT_SECRET']
scope = app.config['SCOPE']
authority = app.config['AUTHORITY']
if authenticate_mode == '':
return 'Please specify one of the two authentication modes in config.py file'
if authenticate_mode.lower() != 'masteruser' and authenticate_mode.lower() != 'serviceprincipal':
return 'Please specify one of the two authentication modes [serviceprincipal or masteruser] in config.py file'
if authenticate_mode.lower() == 'serviceprincipal' and tenant_id == '':
return 'Tenant ID is not provided in config.py file'
if client_id == '':
return 'Client ID is not provided in config.py file'
if authenticate_mode.lower() == 'masteruser':
if username == '':
return 'Master account username is not provided in config.py file'
elif password == '':
return 'Master account password is not provided in config.py file'
if authenticate_mode.lower() == 'serviceprincipal' and client_secret == '':
return 'Client secret is not provided in config.py file'
if scope == '':
return 'Scope is not provided in config.py file'
if authority == '':
return 'Authority URL is not provided in config.py file'