oauth2

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TokenAccess

type TokenAccess struct {
	AccessToken        string     `json:"access_token"`
	TokenType          string     `json:"token_type"`
	ExpiresIn          int        `json:"expires_in"`
	RefreshToken       string     `json:"refresh_token"`
	Scope              string     `json:"scope"`
	LastAuthentication *time.Time `json:"-"`
}

TokenAccess is a access token returned from the OAuth2 integration

type TokenManager

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

TokenManager manages the life cycle and token's cache

func NewTokenManager

func NewTokenManager(
	client *http.Client,
	clientID,
	clientSecret,
	grantType string,
) *TokenManager

NewTokenManager creates a new instance of token manager

func (*TokenManager) GetAccessToken

func (tm *TokenManager) GetAccessToken(ctx context.Context, scope string) (string, error)

GetAccessToken returns a string of access token data

func (*TokenManager) GetTokenType

func (tm *TokenManager) GetTokenType(ctx context.Context, scope string) (string, error)

func (*TokenManager) SendAsGet

func (tm *TokenManager) SendAsGet()

SendAsGet implements TokenManagerProvider.

func (*TokenManager) SendAsPost

func (tm *TokenManager) SendAsPost()

SendAsPost implements TokenManagerProvider.

func (*TokenManager) SetAuthorizationHeader

func (tm *TokenManager) SetAuthorizationHeader(ctx context.Context, r *http.Request, scope string) error

SetAuthorizationHeader injects in request the authorization header Format:

  • "Authorization <token_type> <token_access>"

Parameters

  • ctx: Context for cancel operations
  • r: A pointer of request to inject the header
  • scope: The token scope for recover from cache or make new authentication if cache is empty

func (*TokenManager) WithAuthenticationURL

func (tm *TokenManager) WithAuthenticationURL(url string)

WithAuthenticationURL implements TokenManagerProvider.

func (*TokenManager) WithOptionalParams

func (tm *TokenManager) WithOptionalParams(params map[string]string)

WithOptionalParams implements TokenManagerProvider.

Jump to

Keyboard shortcuts

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