clientcredentials

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package clientcredentials helps with oauth2 client-credentials flow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is context for invokations with client-credentials flow.

func New

func New(options Options) *Client

New creates a client.

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do sends an HTTP request.

type Options

type Options struct {
	TokenURL     string
	ClientID     string
	ClientSecret string
	Scope        string
	HTTPClient   *http.Client

	// 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
}

Options define client options.

Jump to

Keyboard shortcuts

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