curl使用变量传递身份验证

时间:2017-10-06 14:29:17

标签: bash variables curl

有关如何在curl中使用变量传递身份验证的任何建议吗?

这就是我所拥有的,尝试没有引号,但没有运气。

 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 个答案:

答案 0 :(得分:1)

Shell变量仅在双引号内展开,而不是在单引号内:

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

答案 1 :(得分:0)

你试过了吗?

--user "${USERNAME}:${PASSWORD}"
相关问题