Documentation
¶
Overview ¶
Package oauth signs a user in to the Avatar API with the browser, the way an MCP client does: the API names its authorization server (/.well-known/oauth-protected-resource), the CLI registers itself there as a public client for one loopback redirect, sends the user to the authorization page with PKCE, takes the code on that redirect and trades it for tokens. The access token is short-lived; Refresh trades the refresh token for a new pair.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Server ¶
type Server struct {
// Resource is the protected resource the tokens are for.
Resource string
Authorization string
Token string
Registration string
}
Server is the authorization server the Avatar API trusts.
type Tokens ¶
Tokens is one token answer.
func Login ¶
func Login(ctx context.Context, hc *http.Client, s *Server, open func(string) error, show func(string)) (string, *Tokens, error)
Login runs the browser sign-in. open is given the authorization URL (and may fail: the URL is also handed to show, for the user to open by hand). It returns the registered client id with the tokens; refreshing needs it.