clientcredentials

package
v0.14.1-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMethod

type AuthMethod string
const (
	AuthMethodBasicAuth   AuthMethod = "basic_auth"
	AuthMethodRequestBody AuthMethod = "request_body"
)

type Config

type Config struct {
	TokenURL     string         `mapstructure:"token_url"     validate:"required,url"`
	ClientID     string         `mapstructure:"client_id"     validate:"required"`
	ClientSecret string         `mapstructure:"client_secret" validate:"required"`
	AuthMethod   AuthMethod     `mapstructure:"auth_method"   validate:"omitempty,oneof=basic_auth request_body"`
	Scopes       []string       `mapstructure:"scopes"`
	TTL          *time.Duration `mapstructure:"cache_ttl"`
}

func (*Config) Apply

func (c *Config) Apply(_ context.Context, req *http.Request) error

func (*Config) Hash

func (c *Config) Hash() []byte

func (*Config) Token

func (c *Config) Token(ctx context.Context) (*TokenInfo, error)

type TokenEndpointResponse

type TokenEndpointResponse struct {
	*TokenInfoResponse
	*TokenErrorResponse
}

func (TokenEndpointResponse) TokenInfo

func (r TokenEndpointResponse) TokenInfo() (*TokenInfo, error)

type TokenErrorResponse

type TokenErrorResponse struct {
	ErrorType        string `json:"error,omitempty"`
	ErrorDescription string `json:"error_description,omitempty"`
	ErrorURI         string `json:"error_uri,omitempty"`
}

func (*TokenErrorResponse) Error

func (e *TokenErrorResponse) Error() string

type TokenInfo

type TokenInfo struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	TokenType    string    `json:"token_type"`
	Expiry       time.Time `json:"expiry"`
	Scopes       []string  `json:"scopes"`
}

type TokenInfoResponse

type TokenInfoResponse struct {
	AccessToken  string `json:"access_token,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	TokenType    string `json:"token_type,omitempty"`
	ExpiresIn    int64  `json:"expires_in,omitempty"`
	Scope        string `json:"scope,omitempty"`
}

func (*TokenInfoResponse) Type

func (t *TokenInfoResponse) Type() string

Jump to

Keyboard shortcuts

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