誰もが混乱しないように、質問を 2 つの部分に分けて再構成します。
最初:「BASIC認証を使用して、ブラウザで認証済みのHTTPリクエストを作成するにはどうすればよいですか?」.
ブラウザーでは、プロンプトが表示されるのを待つか、次の形式に従う場合は URL を編集して、最初に http 基本認証を行うことができます。http://myusername:mypassword@somesite.com
注意:コマンドラインとcurlがインストールされている場合、質問に記載されているcurlコマンドはまったく問題ありません。;)
参考文献:
また、CURLのマニュアルページによるとhttps://curl.haxx.se/docs/manual.html
HTTP
Curl also supports user and password in HTTP URLs, thus you can pick a file
like:
curl http://name:passwd@machine.domain/full/path/to/file
or specify user and password separately like in
curl -u name:passwd http://machine.domain/full/path/to/file
HTTP offers many different methods of authentication and curl supports
several: Basic, Digest, NTLM and Negotiate (SPNEGO). Without telling which
method to use, curl defaults to Basic. You can also ask curl to pick the
most secure ones out of the ones that the server accepts for the given URL,
by using --anyauth.
NOTE! According to the URL specification, HTTP URLs can not contain a user
and password, so that style will not work when using curl via a proxy, even
though curl allows it at other times. When using a proxy, you _must_ use
the -u style for user and password.
2 番目の本当の質問は、「しかし、somesite.com では、認証プロンプトがまったく表示されず、認証されていないというページだけが表示されます。あるサイトは基本認証ワークフローを正しく実装していませんでしたか、それとも何かありますか?」他に私がしなければならないことはありますか?」
curl のドキュメントによると、この-u
オプションは多くの認証方法をサポートしており、Basic がデフォルトです。