transport

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func (*TokenSource) Refresh

func (s *TokenSource) Refresh() (*oauth2.Token, error)

func (*TokenSource) Token

func (s *TokenSource) Token() (*oauth2.Token, error)

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.

Jump to

Keyboard shortcuts

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