Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL won't prompt me for password using GitHub API

I'm following GitHub's tutorial on using their API. In my Git Bash command prompt, I type the following

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

This pulls in the JSON like it's supposed to. However, when I type

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

It just prints a new line, as if it's waiting for me to finish the command or something. I need to press CTRL C to escape. I have tried different variations too,

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

And nothing is working. What am I doing wrong?

like image 523
amallard Avatar asked Feb 14 '26 07:02

amallard


2 Answers

This turns out to be a known issue (https://github.com/curl/curl/issues/573).

The workaround: prepend "winpty" to the curl command. i.e.

winpty curl ...
like image 198
Xiangming Hu Avatar answered Feb 17 '26 23:02

Xiangming Hu


-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.

So I guess you might have two options. One is to enter the password when you get the new line. The other is to include the password after your username separated by a colon.

like image 39
Imposter Avatar answered Feb 17 '26 22:02

Imposter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!