.netrc support for arbitrary headers
I frequently encounter apis that want something like X-Token: <token> or Authorization: <token> (with no prefix) - would be nice to be able to tell xh to take password as token from .netrc. Not sure how would that look like syntactically. :)
Would sessions work?
.netrc is a weird piece of legacy compatibility that I'd rather not extend unless there's some existing standard for it.
Eh, sessions are httpie-specific, while I reuse netrc between many tools. But if it doesn't seem right, feel free to close the ticket. :)
Do the other tools support headers in netrc files? In that case it might make sense to bring xh in line.
ehh couldn't find a tool that does anything like that. I was drawn to xh initially because of that -A bearer support, worked well for a subset of APIs — but obviously when you get used to convenience you end up wanting more. :)
Maybe we could introduce header as Auth Type e.g. --auth-type=header --auth=x-api-key:API_KEY? On its own, it wouldn't behave any differently than passing a header directly, but it would support reading it from .netrc
$ cat ~/.netrc
machine httpbin.org password x-api-key:12345
$ xh --offline -A header httpbin.org/get
GET /get HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, br, zstd
X-Api-Key: 12345 # <------- header read from .netrc
Connection: keep-alive
Host: httpbin.org
User-Agent: xh/0.23.1
With that being said, this might be stretching .netrc beyond its intended use. Not to mention that that we would be introducing an auth type that likely wouldn't be useful in most cases.
Yeah, just having a little command line script to read from .netrc is more composable, like xh httpbin.org/get x-api-key:$(netrc httpbin.org). Only the fact that domain is repeated sucks somewhat. :)