oauth

package
v0.0.0-...-5c8abdd Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// GoogleAuthEndpoint is the Google authentication endpoint.
	GoogleAuthEndpoint = google.Endpoint

	// PhotosLibraryScope is Google Photos OAuth2 scope.
	PhotosLibraryScope = "https://www.googleapis.com/auth/photoslibrary"

	ErrTokenIsNil = errors.New("OAuth 2.0 token is nil")
)

Functions

func Client

func Client(ctx context.Context, config *Config, token *oauth2.Token) (*http.Client, error)

Client returns an authenticated client using the specified token.

func GetToken

func GetToken(ctx context.Context, config *Config) (*oauth2.Token, error)

GetToken refresh the provided token or create a new OAuth 2.0 token if the provided one is nil.

func RefreshToken

func RefreshToken(ctx context.Context, config *Config, token *oauth2.Token) (*oauth2.Token, error)

RefreshToken refresh the provided token if needed.

Types

type Config

type Config struct {
	// OAuth's application ID.
	ClientID string
	// OAuth's application secret.
	ClientSecret string

	// Logger function for debug.
	Logf func(format string, args ...interface{})
	// contains filtered or unexported fields
}

Config represents a config for the OAuth 2.0 flow.

Jump to

Keyboard shortcuts

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