credentials

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 15

Documentation

Index

Constants

View Source
const ApiTokenHeaderKey = "Authorization"
View Source
const ApiTokenHeaderValuePrefix = "Bearer"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ApiToken                        string `json:"apiToken,omitempty"`
	ClientCredentialsApiTokenIssuer string `json:"apiTokenIssuer,omitempty"`
	ClientCredentialsApiAudience    string `json:"apiAudience,omitempty"`
	ClientCredentialsClientId       string `json:"clientId,omitempty"`
	ClientCredentialsClientSecret   string `json:"clientSecret,omitempty"`
	ClientCredentialsScopes         string `json:"scopes,omitempty"`
}

type Credentials

type Credentials struct {
	Method  CredentialsMethod `json:"method,omitempty"`
	Config  *Config           `json:"config,omitempty"`
	Context context.Context
}

func NewCredentials

func NewCredentials(config Credentials) (*Credentials, error)

func (*Credentials) GetApiTokenHeader

func (c *Credentials) GetApiTokenHeader() *HeaderParams

func (*Credentials) GetHttpClientAndHeaderOverrides deprecated

func (c *Credentials) GetHttpClientAndHeaderOverrides(retryParams retryutils.RetryParams, debug bool) (*http.Client, []*HeaderParams)

GetHttpClientAndHeaderOverrides The main export the client uses to get a configuration with the necessary httpClient and header overrides based on the chosen credential method.

Deprecated: use GetHttpClientAndHeaderOverridesWithBase, which can wrap a caller-provided base http.Client. This variant is retained for backward compatibility and behaves as if no base client were provided.

func (*Credentials) GetHttpClientAndHeaderOverridesWithBase added in v0.8.2

func (c *Credentials) GetHttpClientAndHeaderOverridesWithBase(retryParams retryutils.RetryParams, debug bool, baseClient *http.Client) (*http.Client, []*HeaderParams)

GetHttpClientAndHeaderOverridesWithBase returns the httpClient and header overrides for the chosen credential method. When the method requires an OAuth2-enabled client (ClientCredentials), baseClient (if non-nil) is wrapped so its settings are preserved; otherwise the returned client is nil and the caller should keep its existing client.

func (*Credentials) ValidateCredentialsConfig

func (c *Credentials) ValidateCredentialsConfig() error

type CredentialsMethod

type CredentialsMethod string

Available credential methods

const (
	// No credentials (default)
	CredentialsMethodNone CredentialsMethod = "none"
	// API Token credentials (will be sent in "Authorization: Bearer $TOKEN" header)
	CredentialsMethodApiToken CredentialsMethod = "api_token"
	// Client Credentials flow will be performed, resulting token will be sent in "Authorization: Bearer $TOKEN" header
	CredentialsMethodClientCredentials CredentialsMethod = "client_credentials"
)

type HeaderParams

type HeaderParams struct {
	Key   string
	Value string
}

Jump to

Keyboard shortcuts

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