Documentation ¶
Index ¶
- type ErrorResponse
- type HttpClientFactory
- type OauthClient
- func (c *OauthClient) ClientCredentials(appID string, scope string) (*TokenResponse, *ErrorResponse, error)
- func (c *OauthClient) GetClient() (*restapi.RestClient, error)
- func (c *OauthClient) GetLastResponseHeaders() http.Header
- func (c *OauthClient) GetOauthToken() (*TokenResponse, error)
- func (c *OauthClient) GetRestClient(token *TokenResponse) (*restapi.RestClient, error)
- func (c *OauthClient) RefreshToken(appID string, refreshToken string) (*TokenResponse, *ErrorResponse, error)
- func (c *OauthClient) ResourceOwner(appID string, scope string, owner string, ownerPassword string) (*TokenResponse, *ErrorResponse, error)
- type OauthConfig
- type TokenResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { Error string `json:"error"` Description string `json:"error_description"` }
ErrorResponse repsents a failed response
type HttpClientFactory ¶
type OauthClient ¶
type OauthClient struct { Service string Client *http.Client Headers map[string]string ClientID string ClientSecret string SourceHeader string ResponseHeaders http.Header AppID string Scope string Token string SkipCertVerify bool }
OauthClient represents a stateful Oauth client
func GetNewClient ¶
func GetNewClient(service string, httpFactory HttpClientFactory) (*OauthClient, error)
GetNewClient creates a new client for the specified endpoint
func GetNewConfidentialClient ¶
func GetNewConfidentialClient(service string, clientID string, clientSecret string, httpFactory HttpClientFactory) (*OauthClient, error)
GetNewConfidentialClient creates a new client for the specified endpoint
func (*OauthClient) ClientCredentials ¶
func (c *OauthClient) ClientCredentials(appID string, scope string) (*TokenResponse, *ErrorResponse, error)
func (*OauthClient) GetClient ¶
func (c *OauthClient) GetClient() (*restapi.RestClient, error)
GetClient creates REST client
func (*OauthClient) GetLastResponseHeaders ¶
func (c *OauthClient) GetLastResponseHeaders() http.Header
GetLastResponseHeaders returns the response header for the previous REST call
func (*OauthClient) GetOauthToken ¶
func (c *OauthClient) GetOauthToken() (*TokenResponse, error)
GetOauthToken obtains OAuth token string
func (*OauthClient) GetRestClient ¶
func (c *OauthClient) GetRestClient(token *TokenResponse) (*restapi.RestClient, error)
GetRestClient returns rest client directly with oauth token
func (*OauthClient) RefreshToken ¶
func (c *OauthClient) RefreshToken(appID string, refreshToken string) (*TokenResponse, *ErrorResponse, error)
func (*OauthClient) ResourceOwner ¶
func (c *OauthClient) ResourceOwner(appID string, scope string, owner string, ownerPassword string) (*TokenResponse, *ErrorResponse, error)
ResourceOwner implements the ResourceOwner flow
type OauthConfig ¶
type OauthConfig struct { ClientID string `json:"clientID" structs:"clientID" mapstructure:"clientID"` ClientSecret string `json:"clientSecret" structs:"clientSecret" mapstructure:"clientSecret"` ServiceURL string `json:"serviceUrl" structs:"serviceUrl" mapstructure:"serviceUrl"` AppID string `json:"appID" structs:"appID" mapstructure:"appID"` Scope string `json:"scope,omitempty" structs:"scope" mapstructure:"scope"` Policies []string `json:"policies,omitempty" structs:"policies" mapstructure:"policies"` SkipCertVerify bool `json:"skipCertVerify,omitempty" structs:"skipCertVerify" mapstructure:"skipCertVerify"` }
OauthConfig represents configuration used to create Oauth clients
func GetConfig ¶
func GetConfig(configPath string) (*OauthConfig, error)
GetConfig reads config from a file specified as arg or from the environment
Click to show internal directories.
Click to hide internal directories.