1

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"

2 Answers 2

1

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"
Sign up to request clarification or add additional context in comments.

1 Comment

Ha, I missed that. This is almost certainly the issue.
1

Have you tried:

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.