The :auth
header is composed of a base plugin, and two derived plugins.
The :auth
plugin adds a method to add a self-generated token to the “authorization” header:
http = HTTPX.plugin(:auth)
# authorization: AUTH-TOKEN
http.authorization("AUTH-TOKEN").get("https://api.myapp.com/resources")
# authorization: Bearer AUTH-TOKEN
http.bearer_auth("AUTH-TOKEN").get("https://api.myapp.com/resources")
The :basic_auth
plugin can create an HTTP Basic Auth compatible header based on a username and password.
http = HTTPX.plugin(:basic_auth)
http.basic_auth("user", "pass").get("https://api.myapp.com/resources")
The :digest_auth
plugin provides an API to authenticate requests using HTTP Digest access authentication
http = HTTPX.plugin(:digest_auth)
http.digest_auth("user", "pass").get("https://api.myapp.com/resources")
Note: due to the required extra-roundtrip, requests will be executed one at a time.
(available since v0.15.0
).
The :ntlm_auth
plugin can provides an API to authenticate requests using NTLM auth
http = HTTPX.plugin(:ntlm_auth)
http.ntlm_auth("user", "pass", "Domain").get("https://api.myapp.com/resources")
Next: Follow Redirects