v0.0.0-...-2658d01 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2022 License: MIT Imports: 10 Imported by: 1




This section is empty.


This section is empty.


This section is empty.


type CodeReceiver

type CodeReceiver struct {
	State string
	// contains filtered or unexported fields

func NewCodeReceiver

func NewCodeReceiver() (*CodeReceiver, error)

func (CodeReceiver) Code

func (c CodeReceiver) Code() <-chan string

type Config

type Config struct {
	// Required
	OAuth2Config *oauth2.Config

	// Required if TokenFile is empty
	Name string

	AuthCodeOptions []oauth2.AuthCodeOption

	// Defaults to <UserCacheDir>/<Name>/token.json
	TokenFile string

Config encapsulates typical OAuth2 authorization flow:

  1. Try to restore previously-saved token,
  2. If not available, start a local server for receiving code and prompt its URL,
  3. Obtain an access token when code is received,
  4. Store the token for later use.

func (*Config) AuthorizeByTemporaryServer

func (c *Config) AuthorizeByTemporaryServer(ctx context.Context, prompt func(url string) error) (*oauth2.Token, error)

func (*Config) CreateOAuth2Client

func (c *Config) CreateOAuth2Client(ctx context.Context) (*http.Client, error)

CreateOAuth2Client handles a typical authorization flow. See Config.

func (*Config) DeleteTokenFile

func (c *Config) DeleteTokenFile() (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL