cache

package
v0.85.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 7 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 FileTokenCacheOption

type FileTokenCacheOption func(*fileTokenCache)

func WithFileLocation

func WithFileLocation(fileLocation string) FileTokenCacheOption

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 NewFileTokenCache

func NewFileTokenCache(opts ...FileTokenCacheOption) (TokenCache, error)

NewFileTokenCache creates a new FileTokenCache. By default, the cache is stored in "~/.databricks/token-cache.json". The cache file is created if it does not already exist. The cache file is created with owner permissions 0600 and the directory is created with owner permissions 0700. If the cache file is corrupt or if its version does not match tokenCacheVersion, an error is returned.

Jump to

Keyboard shortcuts

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