auth

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(src TokenSource) *http.Client

Types

type Config

type Config struct {
	AuthURL *url.URL
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(httpClient *http.Client) *Config

func (*Config) NewTokenFromCredentials

func (c *Config) NewTokenFromCredentials(ctx context.Context, username, password string) (*Token, error)

type RetrieveError

type RetrieveError struct {
	Response *http.Response
	Body     []byte
}

func (*RetrieveError) Error

func (r *RetrieveError) Error() string

type Token

type Token struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	UserID       string `json:"user_id"`
	DeviceID     string `json:"device_id"`
}

func (*Token) SetAuthHeader

func (t *Token) SetAuthHeader(r *http.Request)

type TokenSource

type TokenSource interface {
	Token() (*Token, error)
}

func BasicTokenSource

func BasicTokenSource(t *Token) TokenSource

type Transport

type Transport struct {
	Source TokenSource
	Base   http.RoundTripper
}

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip authorizes and authenticates the request with an access token from Transport's Source.

Jump to

Keyboard shortcuts

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