Reputation: 67
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
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