auth

package
v0.64.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2025 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Overview

Package auth is an internal package that provides authentication utilities.

IMPORTANT: This package is not meant to be used directly by consumers of the SDK and is subject to change without notice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*cachedTokenSource)

func WithAsyncRefresh

func WithAsyncRefresh(b bool) Option

WithAsyncRefresh enables or disables the asynchronous token refresh.

func WithCachedToken

func WithCachedToken(t *oauth2.Token) Option

WithCachedToken sets the initial token to be used by a cached token source.

type TokenSource added in v0.58.0

type TokenSource interface {
	// Token returns a token or an error. Token must be safe for concurrent use
	// by multiple goroutines. The returned Token must not be modified.
	Token(context.Context) (*oauth2.Token, error)
}

A TokenSource is anything that can return a token.

func NewCachedTokenSource

func NewCachedTokenSource(ts TokenSource, opts ...Option) TokenSource

NewCachedTokenProvider wraps a TokenSource to cache the tokens it returns. By default, the cache will refresh tokens asynchronously a few minutes before they expire.

The token cache is safe for concurrent use by multiple goroutines and will guarantee that only one token refresh is triggered at a time.

The token cache does not take care of retries in case the token source returns and error; it is the responsibility of the provided token source to handle retries appropriately.

If the TokenSource is already a cached token source (obtained by calling this function), it is returned as is.

type TokenSourceFn added in v0.58.0

type TokenSourceFn func(context.Context) (*oauth2.Token, error)

TokenSourceFn is an adapter to allow the use of ordinary functions as TokenSource.

Example:

   ts := TokenSourceFn(func(ctx context.Context) (*oauth2.Token, error) {
		return &oauth2.Token{}, nil
   })

func (TokenSourceFn) Token added in v0.58.0

func (fn TokenSourceFn) Token(ctx context.Context) (*oauth2.Token, error)

Directories

Path Synopsis
Package dataplane is an experimental package that provides a token source to directly access Databricks data plane.
Package dataplane is an experimental package that provides a token source to directly access Databricks data plane.

Jump to

Keyboard shortcuts

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