Documentation
¶
Overview ¶
Package auth implements the logic required to authenticate the user and generate access tokens for use with GCR.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GCRLoginAgent ¶
type GCRLoginAgent struct {
// Whether to execute OpenBrowser when authenticating the user.
AllowBrowser bool
// Read input from here; if nil, uses os.Stdin.
In io.Reader
// Write output to here; if nil, uses os.Stdout.
Out io.Writer
// Open the browser for the given url. If nil, uses webbrowser.Open.
OpenBrowser func(url string) error
}
GCRLoginAgent implements the OAuth2 login dance, generating an Oauth2 access_token for the user. If AllowBrowser is set to true, the agent will attempt to obtain an authorization_code automatically by executing OpenBrowser and reading the redirect performed after a successful login. Otherwise, it will attempt to use In and Out to direct the user to the login portal and receive the authorization_code in response.
func (*GCRLoginAgent) PerformLogin ¶
func (a *GCRLoginAgent) PerformLogin() (*oauth2.Token, error)
PerformLogin performs the auth dance necessary to obtain an authorization_code from the user and exchange it for an Oauth2 access_token.