I am trying read input to a variable then use this variable in a REST API call data field, but I am unable to escape the variable properly inside quotes.
I have tried backslash before the single quotes, before the double quotes and before both single and double quotes at the same time.
token=$(curl $VAULT_ADDR/v1/auth/ldap/login/$username -d '{"password": "$password"}' -k | jq '.auth.client_token')
echo token
As of now it reads $password as a string. Can't authenticate because the password is wrong then token equals null. I am trying to use the value of variable $password inside double quotes since the data field is supposed to be in JSON-format.
password=hunter2
'{"password": "$password"}'
becomes
'{"password": "hunter2"}'
If I hardcode my password it succeeds