fix and improve auth bash script

Some newlines break the script so remove or escape them.

This also improves the script in the following ways:

1. Make it work with Private Chef
2. Allow use of url parameters (e.g. "/search/client?q=*:*")
3. Treat this script as a file instead of functions that need to be sourced