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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.