Documentation
¶
Index ¶
- type TokenAccess
- type TokenManager
- func (tm *TokenManager) GetAccessToken(ctx context.Context, scope string) (string, error)
- func (tm *TokenManager) GetTokenType(ctx context.Context, scope string) (string, error)
- func (tm *TokenManager) SendAsGet()
- func (tm *TokenManager) SendAsPost()
- func (tm *TokenManager) SetAuthorizationHeader(ctx context.Context, r *http.Request, scope string) error
- func (tm *TokenManager) WithAuthenticationURL(url string)
- func (tm *TokenManager) WithOptionalParams(params map[string]string)
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 ¶
GetAccessToken returns a string of access token data
func (*TokenManager) GetTokenType ¶
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.
Click to show internal directories.
Click to hide internal directories.