user3360847
user3360847

Reputation: 67

curl pass authentication using variable

Any suggestions how to pass authentication using variable in curl?

This is what I have, tried playing without quotes, but no luck.

 curl -X GET "https://example.com/site" \
 -H 'x-auth-email: "${API_EMAIL}"' \
 -H 'x-auth-key: "${API_KEY}"' \
 -H "Content-Type: application/json"

Upvotes: 1

Views: 2938

Answers (2)

Daniel Stenberg
Daniel Stenberg

Reputation: 58014

Shell variables are only expanded within double quotes, not within single quotes:

curl "https://example.com/site" \
 -H "x-auth-email: \"${API_EMAIL}\"" \
 -H "x-auth-key: \"${API_KEY}\"" \
 -H "Content-Type: application/json"

Upvotes: 1

user108471
user108471

Reputation: 2607

Have you tried:

--user "${USERNAME}:${PASSWORD}"

Upvotes: 1

Related Questions