How to use curl with a file for authentification

I having trouble with curl, I can’t manage to use a file to authentificate myselft.
I created a user named bob with a password in a file named “password.txt” with the content : This_is_my_password
I can’t manage to get my authentification token I tried a lot of different ways to use curl but It never worked do you have any ideas ?
The command looks like this :

curl --request POST --data ‘{“password”:"$(cat password.txt)"}’ $VAULT_ADDR/v1/auth/userpass/login/bob | jq -r “.auth.client_token” > bob_token.txt

By the way if I do
curl --request POST --data ‘{“password”:“This_is_my_password”}’ $VAULT_ADDR/v1/auth/userpass/login/bob | jq -r “.auth.client_token” > bob_token.txt

it works I have my token.

Thanks in advance for your ideas.

I believe the single quotes are sending text verbatim as opposed to running the embedded command. You may need to use double quotes and escape the ones embedded in the json string like this:

curl --request POST --data "{\"password\":\"$(cat password.txt)\"}" $VAULT_ADDR/v1/auth/userpass/login/bob | jq -r ".auth.client_token" > bob_token.txt
1 Like

Incredible my friend ! It works thanks a lot have a wonderful week <3