2016-08-01 9 views
1

Ich folge GitHub's tutorial bei der Verwendung ihrer API. In meiner Git Bash-Eingabeaufforderung ich folgendecURL fragt mich nicht nach Passwort mit GitHub API

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

Diese im JSON zieht wie es sollte. Aber wenn ich tippe

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

Es druckt nur eine neue Zeile, als ob es auf mich wartet, um den Befehl oder etwas zu beenden. Ich muss CTRL C drücken, um zu entkommen. Ich habe auch verschiedene Varianten ausprobiert,

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

Und nichts funktioniert. Was mache ich falsch?

Antwort

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. 

Also ich denke, Sie könnten zwei Möglichkeiten haben. Eine besteht darin, das Passwort einzugeben, wenn Sie die neue Zeile erhalten. Der andere besteht darin, das Passwort nach Ihrem Benutzernamen durch einen Doppelpunkt getrennt zu geben.

+0

'curl -i -u BENUTZERNAME: PASSWORT https: // api ...' hat funktioniert. Vielen Dank. Aber warum funktioniert es nicht auf die erste Art? (Wenn Sie nur den Befehl eingeben, funktioniert das Kennwort in einer neuen Zeile nicht.) Wenn Sie das Kennwort in den Befehl eingeben, bleibt das Kennwort in der Shell-Historie. – amallard

+0

Ich bin mir nicht sicher. Auf meinem System, Darwin Kernel Version 15.2.0, werde ich nach einem Passwort gefragt. Ich könnte vorschlagen, die Manpage zu überprüfen. Mann curl von Ihrem Terminal. – Imposter

Verwandte Themen