Get secured application example working; clean up code; add comments / docstrings.