Documentation ¶
Index ¶
- func WithClientID(id string) func(*AuthFlow)
- func WithClientSecret(secret string) func(*AuthFlow)
- func WithOwnerType(ownerType string) func(*AuthFlow)
- func WithPassword(password string) func(*AuthFlow)
- func WithRedirectURI(uri string) func(*AuthFlow)
- func WithScope(scope string) func(*AuthFlow)
- func WithState(state string) func(*AuthFlow)
- func WithUserName(username string) func(*AuthFlow)
- type Auth
- type AuthCodeRequest
- type AuthFlow
- func (flow *AuthFlow) FinalizeAuthCode(ctx context.Context, code string) (*OAuth2AccessToken, error)
- func (flow *AuthFlow) InitAuthCode() (string, error)
- func (flow *AuthFlow) InitClientCredentials(ctx context.Context) (*OAuth2AccessToken, error)
- func (flow *AuthFlow) InitResourceOwner(ctx context.Context) (*OAuth2AccessToken, error)
- type AuthFlowOption
- type BasicAuth
- type Client
- func (c *Client) Delete(endpoint string, options ...RequestOption) (*Response, error)
- func (c *Client) Get(endpoint string, options ...RequestOption) (*Response, error)
- func (c *Client) Patch(endpoint string, options ...RequestOption) (*Response, error)
- func (c *Client) Post(endpoint string, options ...RequestOption) (*Response, error)
- func (c *Client) Put(endpoint string, options ...RequestOption) (*Response, error)
- func (c *Client) Request(method string, endpoint string, options ...RequestOption) (*Response, error)
- type ClientCredentialsRequest
- type Error
- type OAuth2AccessToken
- type RequestOption
- func WitchContext(ctx context.Context) RequestOption
- func WithBody(body io.Reader) RequestOption
- func WithContentType(contentType string) RequestOption
- func WithHeader(name, value string) RequestOption
- func WithJSONBody(content interface{}) RequestOption
- func WithQuery(query url.Values) RequestOption
- func WithQueryValue(key, value string, append bool) RequestOption
- type ResourceOwnerRequest
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithClientID ¶
WithClientID is used to set Client ID for Oauth2 flow
func WithClientSecret ¶
WithClientSecret is used to set Client Secret for Oauth2 flow
func WithOwnerType ¶
WithOwnerType is used to set Owner Type for Oauth2 flow
func WithPassword ¶
WithPassword is used to set password for Oauth2 flow
func WithRedirectURI ¶
WithRedirectURI is used to set redirect URI for Oauth2 flow
func WithUserName ¶
WithUserName is used to set User Name for Oauth2 flow
Types ¶
type AuthCodeRequest ¶
type AuthCodeRequest struct { GrantType string `json:"grant_type"` ClientID string `json:"client_id"` Scope string `json:"scope"` ClientSecret string `json:"client_secret"` Code string `json:"code"` RedirectURI string `json:"redirect_uri"` }
AuthCodeRequest is used to initiate Authorization Code flow
type AuthFlow ¶
type AuthFlow struct {
// contains filtered or unexported fields
}
AuthFlow contains parameters of OAuth2 flow
func NewAuthFlow ¶
func NewAuthFlow(url string, params ...AuthFlowOption) *AuthFlow
NewAuthFlow returns a AuthFlow
func (*AuthFlow) FinalizeAuthCode ¶
func (flow *AuthFlow) FinalizeAuthCode(ctx context.Context, code string) (*OAuth2AccessToken, error)
FinalizeAuthCode completes the Authorization Code flow and returns an access token
func (*AuthFlow) InitAuthCode ¶
InitAuthCode is used to initiate Authorization Code flow. It returns an URL the user is to be redirected to in order to complete the flow.
func (*AuthFlow) InitClientCredentials ¶
func (flow *AuthFlow) InitClientCredentials(ctx context.Context) (*OAuth2AccessToken, error)
InitClientCredentials returns an access token using the client credentials
func (*AuthFlow) InitResourceOwner ¶
func (flow *AuthFlow) InitResourceOwner(ctx context.Context) (*OAuth2AccessToken, error)
InitResourceOwner returns an access token for resource owner (user or contact)
type AuthFlowOption ¶
type AuthFlowOption func(*AuthFlow)
AuthFlowOption provdes parameters for AuthFlow
type BasicAuth ¶
type BasicAuth struct {
// contains filtered or unexported fields
}
BasicAuth provides Basic authentication
func NewBasicAuth ¶
NewBasicAuth returns a new BasicAuth
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used to send requests to the API
func (*Client) Delete ¶
func (c *Client) Delete(endpoint string, options ...RequestOption) (*Response, error)
Delete is convenience wrapper around Request() to send a DELETE request
func (*Client) Get ¶
func (c *Client) Get(endpoint string, options ...RequestOption) (*Response, error)
Get is convenience wrapper around Request() to send a GET request
func (*Client) Patch ¶
func (c *Client) Patch(endpoint string, options ...RequestOption) (*Response, error)
Patch is convenience wrapper around Request() to send a Patch request
func (*Client) Post ¶
func (c *Client) Post(endpoint string, options ...RequestOption) (*Response, error)
Post is convenience wrapper around Request() to send a POST request
type ClientCredentialsRequest ¶
type ClientCredentialsRequest struct { GrantType string `json:"grant_type"` ClientID string `json:"client_id"` Scope string `json:"scope"` ClientSecret string `json:"client_secret"` }
revive:disable:exported ClientCredentialsRequest is used to initiate Client Credentials flow
type Error ¶
Error is used to represent errors returned by the API. It contains error message and HTTP code.
type OAuth2AccessToken ¶
type OAuth2AccessToken struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` ExpiresIn int `json:"expires_in"` RefreshToken string `json:"refresh_token"` }
OAuth2AccessToken is a token used for OAuth 2.0
func (*OAuth2AccessToken) ApplyRequestOptions ¶
func (auth *OAuth2AccessToken) ApplyRequestOptions(req *http.Request) error
ApplyRequestOptions implements Auth.ApplyRequestOptions
type RequestOption ¶
type RequestOption func(*requestOptions) error
RequestOption is a function used to set options of a request to the API
func WitchContext ¶
func WitchContext(ctx context.Context) RequestOption
WitchContext is a RequestOption that sets the request's context
func WithBody ¶
func WithBody(body io.Reader) RequestOption
WithBody is a RequestOption that sets the body of the HTTP request
func WithContentType ¶
func WithContentType(contentType string) RequestOption
WithContentType is a RequestOption that sets the Content-Type header of the HTTP request
func WithHeader ¶
func WithHeader(name, value string) RequestOption
WithHeader is a RequestOption that sets a header of the HTTP request
func WithJSONBody ¶
func WithJSONBody(content interface{}) RequestOption
WithJSONBody is a RequestOption that sets the request's body to a JSON string
func WithQuery ¶
func WithQuery(query url.Values) RequestOption
WithQuery is a RequestOption that sets the query part of the HTTP request URL
func WithQueryValue ¶
func WithQueryValue(key, value string, append bool) RequestOption
WithQueryValue is a RequestOption that sets one parameter of the the query part of the HTTP request URL
type ResourceOwnerRequest ¶
type ResourceOwnerRequest struct { GrantType string `json:"grant_type"` ClientID string `json:"client_id"` Scope string `json:"scope"` ClientSecret string `json:"client_secret"` Username string `json:"username"` Password string `json:"password"` }
ResourceOwnerRequest is used to initiate Resource Owner flow