Back to

Package googleclient

Latest Go to latest
Published: Jun 24, 2020 | License: Apache-2.0 | Module:


Package Files

func New

func New(opts Options) (*http.Client, error)

New returns a new http.Client suitable for passing to the New functions from the packages under An interactive OAuth flow is performed if the credentials don't exist in the config file. An attempt to be open a web browser will done if opts.OpenBrowser is true.

TODO(razvanm): add support for refresh tokens. TODO(razvanm): add support for Application Default Credentials.

type Options

type Options struct {
	ClientID     string
	ClientSecret string

	// Scopes indicates what scope to request.
	Scopes []string

	// AccessType indicates what type of access is desireed. The two possible
	// options are oauth2.AccessTypeOnline and oauth2.AccessTypeOffline.
	AccessType oauth2.AuthCodeOption

	// ConfigFile indicates where to look for and save the credentials. On Linux
	// this is something like ~/.config/grail-role-group/credentials.json.
	ConfigFile string

	// OpenBrowser indicates that a browser should be open to obtain the proper
	// credentials if they are missing.
	OpenBrowser bool

Options describes various options that can be used to create the client.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier