gpt4 book ai didi

curl - 如何使用 cURL 设置授权 header

转载 作者:行者123 更新时间:2023-12-03 03:57:42 27 4
gpt4 key购买 nike

如何使用 cURL 传递授权 header ? (在 /usr/bin/curl 中可执行)。

最佳答案

http://curl.se/docs/httpscripting.html

请参阅第 6 部分:HTTP 身份验证

HTTP Authentication

HTTP Authentication is the ability to tell the server your username andpassword so that it can verify that you're allowed to do the request you'redoing. The Basic authentication used in HTTP (which is the type curl uses bydefault) is plain text based, which means it sends username and passwordonly slightly obfuscated, but still fully readable by anyone that sniffs onthe network between you and the remote server.

To tell curl to use a user and password for authentication:

curl --user name:password http://www.example.com

The site might require a different authentication method (check the headersreturned by the server), and then --ntlm, --digest, --negotiate or even--anyauth might be options that suit you.

Sometimes your HTTP access is only available through the use of a HTTPproxy. This seems to be especially common at various companies. A HTTP proxymay require its own user and password to allow the client to get through tothe Internet. To specify those with curl, run something like:

curl --proxy-user proxyuser:proxypassword curl.haxx.se

If your proxy requires the authentication to be done using the NTLM method,use --proxy-ntlm, if it requires Digest use --proxy-digest.

If you use any one these user+password options but leave out the passwordpart, curl will prompt for the password interactively.

Do note that when a program is run, its parameters might be possible to seewhen listing the running processes of the system. Thus, other users may beable to watch your passwords if you pass them as plain command lineoptions. There are ways to circumvent this.

It is worth noting that while this is how HTTP Authentication works, verymany web sites will not use this concept when they provide logins etc. Seethe Web Login chapter further below for more details on that.

关于curl - 如何使用 cURL 设置授权 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3044315/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com