简体   繁体   English

curl:为apache .htaccess文件提供用户和密码

[英]curl: provide user and password for apache .htaccess file

I am using cURL to test some RESTful APIs. 我正在使用cURL来测试一些RESTful API。 Some of these APIs are served from an Apache machine, and protected with user/password combination using simple .httaccess files. 其中一些API由Apache机器提供,并使用简单的.httaccess文件通过用户/密码组合进行保护。

Is there a way to provide cURL with a username / password combination as arguments? 有没有办法为cURL提供用户名/密码组合作为参数?

Use this curl option for the commandline 对命令行使用此curl选项

-u "User:Password"

More details about this parameter can be found from here . 有关此参数的更多详细信息,请参见此处

您可以使用此curl命令,例如:

curl -A "Mozilla" -L 'http://user:password@localhost/api/someapi.php'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM