Documentation
¶
Overview ¶
Package webdaclient is the authenticated HTTP client of the CLI: it attaches the OAuth access token and refreshes it (with refresh token rotation) through the authorization server token endpoint.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSignedOut = errors.New("signed out: run auth to sign in again")
ErrSignedOut is returned when the refresh token is refused: the stored token is deleted, the user must sign in.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
BaseURL string
Name string
// LockFile, when set, is an advisory lock file held around load→refresh→save so concurrent CLI
// processes sharing the token store never spend the same rotating refresh token twice.
LockFile string
// contains filtered or unexported fields
}
Client handles authenticated HTTP calls to one profile, refreshing its OAuth token when needed.
func New ¶
func New(name, baseURL string, store tokenstore.TokenStore, meta *oauth.Metadata, clientID string, hc *http.Client) (*Client, error)
New loads the stored token; refreshing uses the metadata's token endpoint and clientID. A nil hc uses a new http.Client. A legacy token (with a sequence) or a token issued for another server is ignored. The client never forwards the access token on a redirect that leaves the profile origin.
func (*Client) Do ¶
Do attaches the bearer (refreshing first when it expires within 60 s), and on a 401 refreshes once and retries. Only requests to the profile origin carry the token; a request whose body cannot be replayed is not retried.