auth

package
v0.0.0-...-16bd86a Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GDriveService serviceID = iota
	StravaService
)

Variables

This section is empty.

Functions

func StorageTokenSource

func StorageTokenSource(ctx context.Context, provider *Provider, t *oauth2.Token) oauth2.TokenSource

StorageTokenSource will be used by provider.TokenSource method

Types

type Provider

type Provider struct {
	Config  *oauth2.Config
	Storage Storage
}

func NewProvider

func NewProvider(service serviceID, tokenPath, client, secrect, redirect string, store Storage) (*Provider, error)

func (*Provider) AuthCodeURL

func (p *Provider) AuthCodeURL(state string) string

func (*Provider) Client

func (p *Provider) Client(ctx context.Context, t *oauth2.Token) *http.Client

Client is attached to our TokenSource

func (*Provider) Exchange

func (p *Provider) Exchange(ctx context.Context, code string) (*oauth2.Token, error)

Exchange stores a token after retrieval

func (*Provider) TokenSource

func (p *Provider) TokenSource(ctx context.Context, t *oauth2.Token) oauth2.TokenSource

TokenSource can be passed a token which is stored, or when a new one is retrieved, that's stored

type Storage

type Storage interface {
	GetToken() (*oauth2.Token, error)
	SetToken(*oauth2.Token) error
}

Storage is a generic storage interface

Jump to

Keyboard shortcuts

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