Documentation ¶
Overview ¶
Package ogle provides basic and commong utilities to interact with Google APIs from installed apps.
Index ¶
- func Authorize(ctx context.Context, config *oauth2.Config) (*oauth2.Token, error)
- func LoadTokenFromCache(api string) (*oauth2.Token, error)
- func NewClient(ctx context.Context, api string, scopes ...string) (c *http.Client, err error)
- func RemoveTokenFromCache(api string) error
- func SaveTokenToCache(api string, token *oauth2.Token) error
- type TabWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authorize ¶
Authorized launches the OAuth2 flow, by listening to a random port on localhost. It returns the granted oauth2.Token if the flow completes sucessfully. It will report any error during the process, including the user not authorizing the client at all or an error during the token exchange.
func LoadTokenFromCache ¶
LoadTokenFromCache reads the cache file for the provided API and returns a parsed oauth2.Token pointer, or an error if either the file cannot be read or the token is invalid.
func NewClient ¶
NewClient creates a new http.Client that will authorizes calls with the token stored for the given API name in the cache file.
NewClient is designed to provide a valid token when called, for convenience. This implies that if there is no cached credentials, it will start an OAuth2 flow by calling Authorize.
func RemoveTokenFromCache ¶
RemoveTokenFromCache will remove the cache file for the provided API. Future requests using that api name will require re-authentication.
Types ¶
type TabWriter ¶
type TabWriter struct {
// contains filtered or unexported fields
}
TabWriter is a thin wrapper around `text/tabwriter` that prints any interface{} value.
func NewTabWriter ¶
NewTabWriter initializes a TabWriter object with sane defaults shared by all Ogle API clients.