// SetUpAuth configures agent authentication on c. A cookie is created in // c's cookie jar containing credentials derived from the username and // c.Key. c.VisitWebPage is set to VisitWebPage(c). The return is // non-nil only if c.Key is nil. func SetUpAuth(c *httpbakery.Client, u *url.URL, username string) error { if c.Key == nil { return errgo.New("cannot set-up authentication: client key not configured") } SetCookie(c.Jar, u, username, &c.Key.Public) c.VisitWebPage = VisitWebPage(c) return nil }
// SetUpAuth configures form authentication on c. The VisitWebPage field // in c will be set to a function that will attempt form-based // authentication using f to perform the interaction with the user and // fall back to using the current value of VisitWebPage if form-based // authentication is not supported. func SetUpAuth(c *httpbakery.Client, f form.Filler) { c.VisitWebPage = VisitWebPage(c, f, c.VisitWebPage) }