If you have the user credentials for a user that has permissions to perform the API, then you could put them into $HOME/.netrc as such:
machine localhost login that-username-here password that-password-here
where the every other word: machine
, login
, and password
are key words to keep intact) and lock down the permissions of the file appropriately (e.g. chmod go= $HOME/.netrc
) and use curl's --netrc
option:
If used with HTTP, curl will enable user authentication.
curl --netrc "http://localhost:7180/api/v1/clusters/Cluster 1/services/HIVE/config?view=FULL"
I adjusted your curl parameter in two ways:
- changed an assumed typo of "ervices" to "services", and
- quoted the entire thing, to enable one parameter to the curl command (given the space in the "Cluster 1" name)
If you simply lack the password for a different user, that is a different problem, and is when I would recommend creating a separate account for such API calls (or asking for such an account to be created).
read -s -p "Enter a password to display to everyone in the curl command: " password
-- both flags are an extension to POSIX, so may not be available. Otherwise, see thrig's pointer. – Jeff Schaller Jun 01 '16 at 14:04