2016-08-01 18 views
1

APIの使用については、GitHub's tutorialです。私のGit Bashコマンドプロンプトでは、次のように入力します。cURLはGitHub APIを使用してパスワードを要求しません

curl -i https://api.github.com/users/defunkt 

これは、想定されているようにJSONを引き出します。しかし、私が入力するとき

curl -i -u your_username https://api.github.com/users/defunkt 

私はコマンドや何かを終了するのを待っているかのように、ちょうど新しい行を印刷します。私はCTRL Cを押してエスケープする必要があります。

何も問題はありません。私は間違って何をしていますか?

答えて

2
-u, --user <user:password> 
      Specify the user name and password to use for server authentication. Overrides -n, --netrc and --netrc-optional. 

      If you simply specify the user name, curl will prompt for a password. 

      The user name and passwords are split up on the first colon, which makes it impossible to use a colon in the user name with this 
      option. The password can, still. 

      When using Kerberos V5 with a Windows based server you should include the Windows domain name in the user name, in order for the 
      server to successfully obtain a Kerberos Ticket. If you don't then the initial authentication handshake may fail. 

      When using NTLM, the user name can be specified simply as the user name, without the domain, if there is a single domain and 
      forest in your setup for example. 

      To specify the domain name use either Down-Level Logon Name or UPN (User Principal Name) formats. For example, EXAMPLE\user and 
      [email protected] respectively. 

      If you use a Windows SSPI-enabled curl binary and perform Kerberos V5, Negotiate, NTLM or Digest authentication then you can 
      tell curl to select the user name and password from your environment by specifying a single colon with this option: "-u :". 

      If this option is used several times, the last one will be used. 

だから、2つの選択肢があると思います。 1つは、新しい行を取得するときにパスワードを入力することです。もう1つは、ユーザ名の後にコロンで区切ってパスワードを含めることです。

+0

'curl -i -u USERNAME:PASSWORD https:// api ...'が動作しました。ありがとうございました。しかし、なぜそれは最初の方法では動作しませんか? (コマンドを入力するだけで、新しい行のパスワードは機能しません)コマンドにパスワードを厳密に入力すると、シェルの履歴にパスワードが残されます。 – amallard

+0

わかりません。私のシステムでは、ダーウィン・カーネル・バージョン15.2.0、パスワードの入力が求められます。私はマニュアルページをチェックアウトすることを提案することができます。あなたの端末からカールする男。 – Imposter

関連する問題