token

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultTokenProvider

type DefaultTokenProvider struct {
	// contains filtered or unexported fields
}

func NewDefaultTokenProvider

func NewDefaultTokenProvider(cache cache.Cache, fetcher TokenFetcher) *DefaultTokenProvider

func (*DefaultTokenProvider) GetAccessToken

func (p *DefaultTokenProvider) GetAccessToken(ctx context.Context) (string, error)

func (*DefaultTokenProvider) RefreshAccessToken

func (p *DefaultTokenProvider) RefreshAccessToken(ctx context.Context) (string, error)

type TokenFetcher

type TokenFetcher interface {
	// FetchToken retrieves an access token from a remote server
	FetchToken(ctx context.Context) (token string, expiry int64, err error)
	// GenerateCacheKey generates a cache key
	GenerateCacheKey() string
}

type TokenProvider

type TokenProvider interface {
	// GetAccessToken retrieves the access token from either the cache or the remote server.
	GetAccessToken(ctx context.Context) (string, error)

	// RefreshAccessToken forcefully refreshes the access token, regardless of its expiration status.
	RefreshAccessToken(ctx context.Context) (string, error)
}

Jump to

Keyboard shortcuts

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