The README says "Authorization information from .netrc is honored as well", but it's not clear how this is done. The README should be updated to explain this. I'd submit a PR, but I still can't figure it out. Not quite as easy as curl -n.
For now, HTTPie always tries to read the default ~/.netrc file (or ~/_netrc on windows). It's actually the underlying python-requests library that does that.
Hm...I have a ~/.netrc file that works perfectly well with curl, but seems to be completely ignored by HTTPie.
Here is a working example:
Without ~/.netrc:
$ http httpbin.org/basic-auth/httpie/test
HTTP/1.1 401 UNAUTHORIZED
Connection: close
Content-Length: 0
Date: Wed, 10 Apr 2013 16:49:10 GMT
Server: gunicorn/0.16.1
Www-Authenticate: Basic realm="Fake Realm"
Added this to ~/.netrc:
machine httpbin.org
login httpie
password test
And it's picked up:
$ http httpbin.org/basic-auth/httpie/test
HTTP/1.1 200 OK
Connection: close
Content-Length: 47
Content-Type: application/json
Date: Wed, 10 Apr 2013 16:49:23 GMT
Server: gunicorn/0.16.1
{
"authenticated": true,
"user": "httpie"
}
You can also set the --verbose flag to see if HTTPie sends Authorization: Basic xxxxxx.
Actually, you can run $ python -m netrc to see how your ~/.netrc is understood by he netrc module from Python's standard library.
I've opened a pull request to modify the readme with a short example of this.
Just to follow up, I had no value next to one of the login fields in my .netrc that seemed only to bother Python. curl for some reason did not have a problem with it.
Most helpful comment
Actually, you can run
$ python -m netrcto see how your~/.netrcis understood by henetrcmodule from Python's standard library.