Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TokenTransport ¶
func TokenTransport(endpoint string, tokenstore TokenStore, refresher TokenRefresher, clientID string) func(http.RoundTripper) http.RoundTripper
TokenTransport returns a transport wrapper which injects a stored bearer token, refreshes it when needed, and retries once after a 401 with a refreshed token.
Types ¶
type TokenRefresher ¶
type TokenRefresher interface {
RefreshToken(ctx context.Context, config *oauth2.Config, token *oauth2.Token) (*oauth2.Token, error)
}
TokenRefresher exchanges a stored refresh token for a fresh OAuth token.
type TokenSource ¶
type TokenSource struct {
// contains filtered or unexported fields
}
func NewTokenSource ¶
func NewTokenSource(endpoint string, refresher TokenRefresher, store TokenStore, clientID string) *TokenSource
type TokenStore ¶
type TokenStore interface {
// StoreToken stores the token for the given endpoint and issuer. The issuer is
// used to construct the token refresh request and may be different from the
// endpoint if the auth server has a different issuer URL. If the token is nil,
// any existing token for the endpoint should be deleted.
StoreToken(endpoint, issuer string, token *oauth2.Token) error
// Token retrieves the token and issuer for the given endpoint. If no token is
// found, it returns nil for both the token and issuer.
Token(endpoint string) (*oauth2.Token, string, error)
}
TokenStore persists OAuth tokens for a specific auth server endpoint.
Click to show internal directories.
Click to hide internal directories.