cache

package
v0.130.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package cache provides an interface for storing and looking up OAuth tokens.

The cache should be primarily used for user-to-machine (U2M) OAuth flows. In U2M OAuth flows, the application needs to store the token for later use, such as in a separate process, and the cache provides a way to do so without requiring the user to follow the OAuth flow again.

In machine-to-machine (M2M) OAuth flows, the application is configured with a secret and can fetch a new token on demand without user interaction, so the token cache is not necessary.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("token not found")

Functions

This section is empty.

Types

type TokenCache

type TokenCache interface {
	// Store stores the token with the given key, replacing any existing token.
	// If t is nil, it deletes the token.
	Store(key string, t *oauth2.Token) error

	// Lookup looks up the token with the given key. If the token is not found, it
	// returns ErrNotFound.
	Lookup(key string) (*oauth2.Token, error)
}

TokenCache is an interface for storing and looking up OAuth tokens.

func NewInMemoryTokenCache added in v0.130.0

func NewInMemoryTokenCache() TokenCache

NewInMemoryTokenCache returns a TokenCache that stores tokens in process memory only. Tokens do not persist across process restarts. This is the default cache used by PersistentAuth when no WithTokenCache option is provided. Most production consumers should supply a persistent cache implementation (for example, the file-based cache in github.com/databricks/cli/libs/auth/storage).

Jump to

Keyboard shortcuts

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