credentials

package
v0.0.1-dev.6 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoAuthConfigured is returned when no strategy in the default chain
	// could be configured from the resolved profile and environment.
	ErrNoAuthConfigured = errors.New("cannot configure default credentials")

	// ErrAuthTypeNotFound is returned when the profile requests an auth_type
	// that does not match any strategy in the default chain.
	ErrAuthTypeNotFound = errors.New("auth type not found")
)

Functions

func NewDefaultCredentials

func NewDefaultCredentials(opts DefaultCredentialsOptions) auth.Credentials

NewDefaultCredentials returns auth.Credentials that resolve to the first configured authentication strategy on first use.

Strategies are tried in this order:

  1. PAT (pat).
  2. OAuth M2M (oauth-m2m).
  3. Databricks CLI (databricks-cli).
  4. Environment OIDC (env-oidc).
  5. File OIDC (file-oidc).

If the profile sets auth_type, only the strategy with that name is tried. Resolution is deferred until the first auth.Credentials.AuthHeaders call and then memoized, so profile resolution and any network discovery happen lazily and at most once.

func NewM2MCredentials

func NewM2MCredentials(opts M2MOptions) (auth.TokenProvider, error)

NewM2MCredentials returns an auth.TokenProvider that fetches OAuth 2.0 access tokens using the client credentials grant.

The returned provider does not cache tokens or retry on failure. Wrap it with auth.NewCachedTokenProvider and [retrying.NewTokenProvider] as needed.

func NewPATCredentials

func NewPATCredentials(token string) (auth.Credentials, error)

NewPATCredentials returns a Credentials that can be used to authenticate with a Personal Access Token.

func NewU2MCredentials

func NewU2MCredentials(opts U2MOptions) (auth.TokenProvider, error)

NewU2MCredentials returns an auth.TokenProvider that obtains tokens by shelling out to the Databricks CLI.

The returned provider does not cache tokens or retry on failure. Wrap it with auth.NewCachedTokenProvider and [retrying.NewTokenProvider] as needed.

Types

type DefaultCredentialsOptions

type DefaultCredentialsOptions struct {
	// Profile is a pre-resolved profile to use. When nil, the profile is
	// resolved on first use from the default config file (~/.databrickscfg)
	// and DATABRICKS_* environment variables.
	Profile *profiles.Profile
}

DefaultCredentialsOptions configures NewDefaultCredentials.

type M2MOptions

type M2MOptions struct {
	// ClientID is the OAuth client ID (service principal application ID).
	// Required.
	ClientID string

	// ClientSecret is the OAuth client secret. Required.
	ClientSecret string

	// Host is the Databricks workspace or account URL (for example,
	// "https://example.cloud.databricks.com"). Required.
	Host string

	// GroupID is the ID of the group whose role is assumed by the issued token.
	// When empty, no group role is assumed.
	GroupID string

	// Scopes overrides the OAuth scopes requested for the token. If empty,
	// defaults to ["all-apis"].
	Scopes []string

	// HTTPClient is the HTTP client used for OIDC endpoint discovery and
	// for the OAuth token exchange. If nil, [http.DefaultClient] is used.
	HTTPClient *http.Client
}

M2MOptions configures a machine-to-machine (OAuth 2.0 client credentials) auth.TokenProvider.

type U2MOptions

type U2MOptions struct {
	// Profile is the databricks CLI profile name. When set, the CLI is
	// invoked with --profile. Host, when also set, is used as a fallback
	// for older CLI versions that do not support --profile.
	Profile string

	// Host is the workspace or account URL. Required when Profile is empty.
	Host string

	// AccountID is passed as --account-id when invoking the CLI via --host
	// for account-level hosts. Optional.
	AccountID string

	// CLIPath overrides the "databricks" binary to execute. If empty, the
	// binary is looked up in PATH.
	CLIPath string
}

U2MOptions configures a user-to-machine auth.TokenProvider that obtains tokens by shelling out to the Databricks CLI. The CLI must already be authenticated (via "databricks auth login"); this provider does not perform an interactive OAuth flow.

Jump to

Keyboard shortcuts

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