Authentication
The currently supported authentication schemes are Basic and Digest(see auth plugins for more). There are two flags that control authentication:
—auth, -a | Pass a username:password pair asthe argument. Or, if you only specify a username(-a username ), you'll be prompted forthe password before the request is sent.To send an empty password, pass username: .The username:[email protected] URL syntax issupported as well (but credentials passed via -a have higher priority). |
—auth-type, -A | Specify the auth mechanism. Possible values arebasic and digest . The default value isbasic so it can often be omitted. |
Basic auth
- $ http -a username:password example.org
Digest auth
- $ http -A digest -a username:password example.org
Password prompt
- $ http -a username example.org
.netrc
Authentication information from your ~/.netrc
file is by default honored as well.
For example:
- $ cat ~/.netrc
- machine httpbin.org
- login httpie
- password test
- $ http httpbin.org/basic-auth/httpie/test
- HTTP/1.1 200 OK
- [...]
This can be disabled with the —ignore-netrc
option:
- $ http --ignore-netrc httpbin.org/basic-auth/httpie/test
- HTTP/1.1 401 UNAUTHORIZED
- [...]
Auth plugins
Additional authentication mechanism can be installed as plugins.They can be found on the Python Package Index
- httpie-api-auth: ApiAuth
- httpie-aws-auth: AWS / Amazon S3
- httpie-edgegrid: EdgeGrid
- httpie-hmac-auth: HMAC
- httpie-jwt-auth: JWTAuth (JSON Web Tokens)
- httpie-negotiate: SPNEGO (GSS Negotiate)
- httpie-ntlm: NTLM (NT LAN Manager)
- httpie-oauth: OAuth
- requests-hawk: Hawk