Documentation
¶
Overview ¶
Package clientcredentials helps with oauth2 client-credentials flow.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaulIsBadTokenStatus ¶ added in v0.2.0
DefaulIsBadTokenStatus is used as default function when option IsBadTokenStatus is left undefined. DefaulIsBadTokenStatus just checks for status 401.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is context for invokations with client-credentials flow.
type Options ¶
type Options struct {
TokenURL string
ClientID string
ClientSecret string
Scope string
// HTTPClient is the HTTP client to use to make requests.
// If nil, http.DefaultClient is used.
HTTPClient HTTPDoer
// IsTokenStatusCodeOk defines custom function to check whether the
// token server response status is OK.
// If undefined, defaults to nil, which means any 2xx status is OK.
IsTokenStatusCodeOk func(status int) bool
// 0 defaults to 10 seconds. Set to -1 to no soft expire.
//
// Example: consider expire_in = 30 seconds and soft expire = 10 seconds.
// The token will hard expire after 30 seconds, but we will consider it
// expired after (30-10) = 20 seconds, in order to attempt renewal before
// hard expiration.
//
SoftExpireInSeconds int
Cache token.TokenCache
// Time source used to check token expiration.
// If unspecified, defaults to time.Now().
TimeSource func() time.Time
DisableSingleFlight bool
// Logging function, if undefined defaults to log.Printf
Logf func(format string, v ...any)
// Enable debug logging.
Debug bool
// IsBadTokenStatus defines custom function to check whether the
// server response status is bad token.
// If undefined, defaults to DefaulIsBadTokenStatus that just checks
// for status 401.
IsBadTokenStatus func(status int) bool
}
Options define client options.
Click to show internal directories.
Click to hide internal directories.