Documentation ¶
Index ¶
- Variables
- func Auth0ClientInfoTransport(base http.RoundTripper, auth0ClientInfo *Auth0ClientInfo) (http.RoundTripper, error)
- func DebugTransport(base http.RoundTripper, debug bool) http.RoundTripper
- func OAuth2ClientCredentials(ctx context.Context, uri, clientID, clientSecret string) oauth2.TokenSource
- func OAuth2ClientCredentialsAndAudience(ctx context.Context, uri, clientID, clientSecret, audience string) oauth2.TokenSource
- func RetriesTransport(base http.RoundTripper, r RetryOptions) http.RoundTripper
- func StaticToken(token string) oauth2.TokenSource
- func UserAgentTransport(base http.RoundTripper, userAgent string) http.RoundTripper
- func Wrap(base *http.Client, options ...Option) *http.Client
- func WrapWithTokenSource(base *http.Client, tokenSource oauth2.TokenSource, options ...Option) *http.Client
- type Auth0ClientInfo
- type Option
- type RetryOptions
- type RoundTripFunc
Constants ¶
This section is empty.
Variables ¶
var DefaultAuth0ClientInfo = &Auth0ClientInfo{ Name: "go-auth0", Version: auth0.Version, Env: map[string]string{ "go": runtime.Version(), }, }
DefaultAuth0ClientInfo is the default client information sent by the go-auth0 SDK.
var DefaultRetryOptions = RetryOptions{ MaxRetries: 2, Statuses: []int{http.StatusTooManyRequests}, }
DefaultRetryOptions is the default retry configuration used by the SDK. It will only retry on 429 errors and will retry a request twice.
var UserAgent = fmt.Sprintf("Go-Auth0/%s", auth0.Version)
UserAgent is the default user agent string.
Functions ¶
func Auth0ClientInfoTransport ¶ added in v0.16.0
func Auth0ClientInfoTransport(base http.RoundTripper, auth0ClientInfo *Auth0ClientInfo) (http.RoundTripper, error)
Auth0ClientInfoTransport wraps base transport with a customized "Auth0-Client" header.
func DebugTransport ¶
func DebugTransport(base http.RoundTripper, debug bool) http.RoundTripper
DebugTransport wraps base transport with the ability to log the contents of requests and responses.
func OAuth2ClientCredentials ¶
func OAuth2ClientCredentials(ctx context.Context, uri, clientID, clientSecret string) oauth2.TokenSource
OAuth2ClientCredentials sets the oauth2 client credentials.
func OAuth2ClientCredentialsAndAudience ¶ added in v0.10.0
func OAuth2ClientCredentialsAndAudience( ctx context.Context, uri, clientID, clientSecret, audience string, ) oauth2.TokenSource
OAuth2ClientCredentialsAndAudience sets the oauth2 client credentials with a custom audience.
func RetriesTransport ¶ added in v1.0.0
func RetriesTransport(base http.RoundTripper, r RetryOptions) http.RoundTripper
RetriesTransport wraps base transport with retry functionality.
This transport will retry in the following circumstances: Total retries is less than the configured amount AND The configuration specifies to retry on the status OR the error.
func StaticToken ¶
func StaticToken(token string) oauth2.TokenSource
StaticToken sets a static token to be used for oauth2.
func UserAgentTransport ¶
func UserAgentTransport(base http.RoundTripper, userAgent string) http.RoundTripper
UserAgentTransport wraps base transport with a customized "User-Agent" header.
func WrapWithTokenSource ¶ added in v1.0.0
func WrapWithTokenSource(base *http.Client, tokenSource oauth2.TokenSource, options ...Option) *http.Client
WrapWithTokenSource wraps the base client with transports that enable OAuth2 authentication.
Types ¶
type Auth0ClientInfo ¶ added in v0.16.0
type Auth0ClientInfo struct { Name string `json:"name"` Version string `json:"version"` Env map[string]string `json:"env,omitempty"` }
Auth0ClientInfo is the structure used to send client information in the "Auth0-Client" header.
func (*Auth0ClientInfo) IsEmpty ¶ added in v0.16.0
func (td *Auth0ClientInfo) IsEmpty() bool
IsEmpty checks whether the provided Auth0ClientInfo data is nil or has no data to allow short-circuiting the "Auth0-Client" header configuration.
type Option ¶
Option is the type used to configure a client.
func WithAuth0ClientInfo ¶ added in v0.16.0
func WithAuth0ClientInfo(auth0ClientInfo *Auth0ClientInfo) Option
WithAuth0ClientInfo configures the client to overwrite the "Auth0-Client" header.
func WithRetries ¶ added in v1.0.0
func WithRetries(r RetryOptions) Option
WithRetries configures the retry transports on the http client used.
func WithUserAgent ¶
WithUserAgent configures the client to overwrite the user agent header.
type RetryOptions ¶ added in v1.0.0
RetryOptions defines the retry rules that should be followed by the SDK when making requests.
func (*RetryOptions) IsEmpty ¶ added in v1.0.0
func (r *RetryOptions) IsEmpty() bool
IsEmpty checks whether the provided Auth0ClientInfo data is nil or has no data to allow short-circuiting the "Auth0-Client" header configuration.
type RoundTripFunc ¶
RoundTripFunc is an adapter to allow the use of ordinary functions as HTTP round trips.