condensing python code in utils check_credentials