Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrClientIDMustBeSet = errors.New("clientID must be set") ErrTokenURLRequired = errors.New("tokenURL must be set") )
Functions ¶
Types ¶
type ClientConfig ¶
type ClientConfig struct {
// contains filtered or unexported fields
}
type Option ¶
type Option func(*ClientConfig)
func WithAPIClient ¶
func WithAuthURL ¶
func WithClientID ¶
func WithClientSecret ¶
func WithScopes ¶
func WithTLSConfig ¶
func WithTokenURL ¶
type TokenInjector ¶
type TokenInjector struct {
// contains filtered or unexported fields
}
TokenInjector is a struct that implements http.RoundTripper and injects headers into requests.
func NewTokenInjector ¶
func NewTokenInjector( apiClient *http.Client, tokenClient *http.Client, clientCredentialsConfig *clientcredentials.Config, ) *TokenInjector
NewTokenInjector creates a new instance of TokenInjector. It requires an apiClient, tokenClient, and clientCredentialsConfig. The apiClient is used to execute HTTP requests. The tokenClient is used to fetch tokens. The clientCredentialsConfig is used to create a token source. The token is stored in the TokenInjector and reused for subsequent requests. If the token is nil or expired, a new token is fetched. In other cases, the token is reused. The token is injected into the request done by apiClient as a Bearer token.
Click to show internal directories.
Click to hide internal directories.