Documentation
¶
Overview ¶
Package oauth runs the browser login against the Chronos API: the authorization code flow with PKCE, a loopback listener for the redirect, the token exchange and revocation. These protocol requests use form bodies and RFC 6749 errors, which the SDK does not send or parse.
Index ¶
Constants ¶
const ClientID = "chronos-cli"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
BaseURL string
// HTTPClient sends the token and revoke requests. Its redirect policy is
// ignored, since a redirect could carry the form body to another host.
HTTPClient *http.Client
UserAgent string
}
func (*Client) Login ¶
Login opens the browser for the person to approve the login, waits for the redirect to the loopback listener and exchanges the code for a token. It returns when ctx ends or opts.Timeout passes, with the listener closed.
type LoginOptions ¶
type LoginOptions struct {
// Scope is the space-separated scopes to ask for.
Scope string
// DeviceName names this machine on the consent page. Empty sends none.
DeviceName string
Timeout time.Duration
// OpenBrowser is called with the authorization URL once the listener is
// ready.
OpenBrowser func(authorizeURL string)
// Ignored is called when the listener ignores a callback: a wrong state,
// or one after the first.
Ignored func()
}