config

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMethod

type AuthMethod string

AuthMethod represents the authentication method to use

const (
	// AuthMethodToken represents direct token authentication
	AuthMethodToken AuthMethod = "token"
	// AuthMethodClientCredentials represents client credentials grant type
	AuthMethodClientCredentials AuthMethod = "client_credentials"
)

type ClientConfig

type ClientConfig struct {
	// BaseURL is the base URL for the API
	BaseURL string
	// HTTPClient is the HTTP client to use for requests
	HTTPClient *http.Client
	// APIKey is the API key to use for authentication (deprecated, use Token instead)
	APIKey string
	// Timeout is the timeout for requests
	Timeout time.Duration

	// Auth related fields
	// AuthMethod is the authentication method to use
	AuthMethod AuthMethod
	// Token is the direct authentication token to use if AuthMethod is AuthMethodToken
	Token string
	// OAuth2ClientID is the client ID to use for client credentials grant type
	OAuth2ClientID string
	// OAuth2ClientSecret is the client secret to use for client credentials grant type
	OAuth2ClientSecret string
	// contains filtered or unexported fields
}

ClientConfig contains the configuration for the API clients

func DefaultClientConfig

func DefaultClientConfig() *ClientConfig

DefaultClientConfig returns a default configuration for the API clients

func (*ClientConfig) GetToken

func (c *ClientConfig) GetToken(ctx context.Context) (string, error)

GetToken returns the current valid token, fetching a new one if necessary

func (*ClientConfig) WithAPIKey

func (c *ClientConfig) WithAPIKey(apiKey string) *ClientConfig

WithAPIKey sets the API key to use for authentication (deprecated, use WithToken instead)

func (*ClientConfig) WithBaseURL

func (c *ClientConfig) WithBaseURL(baseURL string) *ClientConfig

WithBaseURL sets the base URL for the API

func (*ClientConfig) WithCertificatePath added in v0.0.17

func (c *ClientConfig) WithCertificatePath(certPath *string) *ClientConfig

WithCertificatePath sets the CA certificates from the given path

func (*ClientConfig) WithClientCredentials

func (c *ClientConfig) WithClientCredentials(clientID, clientSecret string) *ClientConfig

WithClientCredentials sets up client credentials grant type authentication

func (*ClientConfig) WithHTTPClient

func (c *ClientConfig) WithHTTPClient(httpClient *http.Client) *ClientConfig

WithHTTPClient sets the HTTP client to use for requests

func (*ClientConfig) WithTimeout

func (c *ClientConfig) WithTimeout(timeout time.Duration) *ClientConfig

WithTimeout sets the timeout for requests

func (*ClientConfig) WithToken

func (c *ClientConfig) WithToken(token string) *ClientConfig

WithToken sets a static token for authentication

type TokenResponse

type TokenResponse struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int    `json:"expires_in"`
	Scope       string `json:"scope,omitempty"`
}

TokenResponse represents the response from the OAuth token endpoint

Jump to

Keyboard shortcuts

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