Some Web APIs requires authenticating via HTTP Basic auth ( i.e. base64 encoded user and password authentication). More...
Public Member Functions | |
template<typename UserType , typename PassType > | |
Authentication (UserType &&username, PassType &&password) | |
Specify username and password for basic auth. | |
Passing an xxhr::Authentication is enough to transmit user and password information. In HTTP there are two ways : Basic and Digest authentication.
It is recommended to use authentication, even the Digest one only on a TLS connection.
In this example we query the Github REST search api, if you've setup 2-Factor Authentication on your github account you should use a github personal access token to test this example and use it in place of password.
Otherwise you'll get an xxhr::Response::status_code 404.
To initiate a Digest authentication use in-place of xxhr::Authentication the xxhr::Digest parameter:
To initiate a Bearer authentication use xxhr::Bearer parameter: