Search code examples
gitgithubcmdgit-bash

github api does not work in git bash, but in cmd it does


Hello when I am testing the github api in Git Bash everything works fine until I use this command:

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

but when I do it in the windows cmd it works perfectly, it instantly asks me for the password,i already tried uninstalling and installing git but it doesn't work.

Here I show what is happening https://www.loom.com/share/8aabb02719424117ad0f70ba40ce5234


Solution

  • I just tested it in a git bash session:

    vonc@vclp MINGW64 ~/git/git (master)
    $ curl -i -u VonC https://api.github.com/users/VonC
    Enter host password for user 'VonC':
    ...
    {
      "login": "VonC",
      ...
    }
    
    

    It does work.

    But my %PATH% (before typing bash) is, from a CMD:

    C:\Users\vonc\git\git>where curl
    C:\Program Files\Git\mingw64\bin\curl.exe
    C:\Windows\System32\curl.exe
    

    So I use the curl from the Git for Windows, before the Windows one.

    Based on your video, and "cURL won't prompt me for password using GitHub API", try adding winpty:

    winpty curl -u <me> https://api.github.com/users/<me>