使用带有用户名和密码的 cURL? [英] Using cURL with a username and password?
本文介绍了使用带有用户名和密码的 cURL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想访问一个需要用户名/密码的 URL.我想尝试使用 curl 访问它.现在我正在做类似的事情:
I want to access a URL which requires a username/password. I'd like to try accessing it with curl. Right now I'm doing something like:
curl http://api.somesite.com/test/blah?something=123
我收到一个错误.我想我需要在上面的命令中指定用户名和密码.
I get an error. I guess I need to specify a username and password along with the above command.
我该怎么做?
推荐答案
使用 -u
标志包含用户名,curl 会提示输入密码:
Use the -u
flag to include a username, and curl will prompt for a password:
curl -u username http://example.com
您也可以在命令中包含密码,但是您的密码将在 bash 历史记录中可见:
You can also include the password in the command, but then your password will be visible in bash history:
curl -u username:password http://example.com
这篇关于使用带有用户名和密码的 cURL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文