Documentation
¶
Overview ¶
Package authtoken provides Keycloak service-account token management with automatic caching and refresh.
The client uses an RWMutex with double-check locking to efficiently cache tokens across concurrent requests, automatically refreshing expired tokens. A configurable expiry buffer prevents race conditions during token refresh.
Basic usage:
client := authtoken.New("https://auth.example.com", "my-realm", "client-id", "client-secret")
token, err := client.GetToken(ctx)
if err != nil {
return err
}
// Use token for API requests
The client is safe for concurrent use. Call InvalidateToken() to force a token refresh on the next request.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoAccessToken = errors.New("authtoken: no access token in response")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) InvalidateToken ¶
func (c *Client) InvalidateToken()
Click to show internal directories.
Click to hide internal directories.