base_client

package
v0.0.0-...-a32337f Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HEADER_USER_AGENT       = http.CanonicalHeaderKey("User-Agent")
	HEADER_ACCEPT           = http.CanonicalHeaderKey("Accept")
	HEADER_CONTENT_TYPE     = http.CanonicalHeaderKey("Content-Type")
	HEADER_WWW_AUTHENTICATE = http.CanonicalHeaderKey("Www-Authenticate")
	HEADER_AUTHORIZATION    = http.CanonicalHeaderKey("Authorization")
)

noinspection ALL

Functions

This section is empty.

Types

type AuthChallenge

type AuthChallenge struct {
	Endpoint, Service, Scope string
}

func GetAuthChallenge

func GetAuthChallenge(header string) *AuthChallenge

type BaseClient

type BaseClient struct {
	// The base URL for requests
	BaseURL *url.URL

	// Resty client
	Resty *resty.Client
}

func New

func New(u string) (*BaseClient, error)

func (*BaseClient) Authenticate

func (c *BaseClient) Authenticate(challenge *AuthChallenge) error

func (*BaseClient) GetToken

func (c *BaseClient) GetToken(request *AuthChallenge) (*Token, error)

func (*BaseClient) R

func (c *BaseClient) R() *resty.Request

type Token

type Token struct {

	// An opaque Bearer token that clients should supply to subsequent requests in the Authorization header.
	Token string `json:"token"`

	// For compatibility with OAuth 2.0, we will also accept token under the name access_token.
	// At least one of these fields must be specified, but both may also appear (for compatibility with older clients).
	// When both are specified, they should be equivalent; if they differ the client's choice is undefined.
	AccessToken string `json:"access_token"`

	// (Optional) The duration in seconds since the token was issued that it will remain valid.
	// When omitted, this defaults to 60 seconds. For compatibility with older clients,
	// a token should never be returned with less than 60 seconds to live.
	ExpiresIn int `json:"expires_in,omitempty"`

	// (Optional) The RFC3339-serialized UTC standard time at which a given token was issued.
	// If issued_at is omitted, the expiration is from when the token exchange completed.
	IssuedAt time.Time `json:"issued_at,omitempty"`

	// (Optional) Token which can be used to get additional access tokens for the same subject with different scopes.
	// This token should be kept secure by the client and only sent to the authorization server which issues bearer
	// tokens. This field will only be set when `offline_token=true` is provided in the request.
	RefreshToken time.Time `json:"refresh_token,omitempty"`
}

Jump to

Keyboard shortcuts

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