credentials

package
v0.72.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CredentialsProvider

type CredentialsProvider interface {
	// SetHeaders sets the credential in the request's headers.
	SetHeaders(r *http.Request) error
}

CredentialsProvider represents anything that can set credentials, such as a token, in the headers of a request.

func NewCredentialsProvider

func NewCredentialsProvider(f func(r *http.Request) error) CredentialsProvider

NewCredentialsProvider returns a new CredentialsProvider that uses the provided function to set headers on the request.

DEPRECATED: Use CredentialsProviderFn instead.

type CredentialsProviderFn added in v0.71.0

type CredentialsProviderFn func(r *http.Request) error

CredentialsProviderFn is an adapter to allow the use of an ordinary function as a CredentialsProvider.

Example:

   cp := CredentialsProviderFn(func(r *http.Request) error {
		return nil
   })

func (CredentialsProviderFn) SetHeaders added in v0.71.0

func (c CredentialsProviderFn) SetHeaders(r *http.Request) error

type OAuthCredentialsProvider

type OAuthCredentialsProvider interface {
	CredentialsProvider
	// Token returns the OAuth token generated by the provider.
	Token(ctx context.Context) (*oauth2.Token, error)
}

OAuthCredentialsProvider is a specialized CredentialsProvider uses and provides an OAuth token.

func NewOAuthCredentialsProvider

func NewOAuthCredentialsProvider(visitor func(r *http.Request) error, tokenProvider func() (*oauth2.Token, error)) OAuthCredentialsProvider

DEPRECATED: Use NewOAuthCredentialsProviderFromTokenSource instead.

func NewOAuthCredentialsProviderFromTokenSource added in v0.70.0

func NewOAuthCredentialsProviderFromTokenSource(ts auth.TokenSource) OAuthCredentialsProvider

NewOAuthCredentialsProviderFromTokenSource returns a new OAuthCredentialsProvider that uses the given TokenSource to get the token.

The returned OAuthCredentialsProvider does not alter the behavior of the token source. For example, it does not implement any caching or retrying logic. It is the responsibility of the TokenSource to implement these behaviors.

Jump to

Keyboard shortcuts

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