Esempio n. 1
0
func WithAuth(c *Client, username, password string) *Client {
	if username != "" && password != "" {
		authFunc := func(req *http.Request) *http.Request {
			req.SetBasicAuth(username, password)
			return req
		}
		c.api = httpctx.WithAuthFunc(authFunc)
		c.Download = downloadFunc(authFunc)
	}
	return c
}
Esempio n. 2
0
func FromPassword(domain, email, password string) *Client {
	e := email
	p := password
	authFunc := func(req *http.Request) *http.Request {
		req.SetBasicAuth(e, p)
		return req
	}

	return &Client{
		domain: domain,
		http:   httpctx.WithAuthFunc(authFunc),
	}
}
Esempio n. 3
0
func FromToken(domain, email, token string) *Client {
	username := fmt.Sprintf("%s/token", email)
	password := token
	authFunc := func(req *http.Request) *http.Request {
		req.SetBasicAuth(username, password)
		return req
	}

	return &Client{
		domain: domain,
		http:   httpctx.WithAuthFunc(authFunc),
	}
}