httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.

Home Page:https://httpie.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add .netrc support when using --auth-type bearer

pwagland opened this issue · comments

Checklist

  • I've searched for similar feature requests. The closest I found is where this was implemented in xh

Enhancement request

When using https, I don't want to have to hard-code my token in all scripts, rather I would like to have a central location where the token can be read from. This already works for the basic authentication type, but not, as far as I can tell, for the bearer auth type.

If this is implemented, then this enhancement request is to document it clearly, what needs to be in the file as https://httpie.io/docs/cli/netrc does not seem to cover it.


Problem it solves

I'm always frustrated when writing a script that I need to hard code the token in it, as it makes the script harder to share.


Additional information, screenshots, or code examples

This is implemented in xh and with the following in the .netrc:

machine host.local.lan password SecretToken

then

xh --json --auth-type bearer "https://host.local.lan/rest/api/latest/…"

Correctly sends the header:

Authorization: Bearer SecretToken

It would be great if httpie would support this same functionality.