The code is set up to handle authorization easily, but it's not implemented. The general outline is this:
Create a new struct like so:
pub struct AuthorizedClient<'a> {
underlying: SnapdClient,
macaroon: Macaroon<'a>
}
Where Macaroon is a newtype over a Cow. Then you can implement GetClient (etc) as for SnapdClient, but override attach_headers to also attach the auth header.
As for getting the credentials, use the /v2/login API, which can be implemented under the hood as a Get, and put a convenience method on SnapdClient called login<'a>(&self) -> AuthorizedClient<'a> {} which creates the client with an owned macaroon.
The code is set up to handle authorization easily, but it's not implemented. The general outline is this:
Create a new struct like so:
Where
Macaroonis a newtype over aCow. Then you can implementGetClient(etc) as forSnapdClient, but overrideattach_headersto also attach the auth header.As for getting the credentials, use the
/v2/loginAPI, which can be implemented under the hood as aGet, and put a convenience method onSnapdClientcalledlogin<'a>(&self) -> AuthorizedClient<'a> {}which creates the client with an ownedmacaroon.