Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidProfile = errors.New("invalid profile")
ErrInvalidProfile is thrown when a profile is missing or invalid.
Functions ¶
func TokenHandler ¶
TokenHandler takes a token source, gets a token, and modifies a request to add the token auth as a header. Uses the CLI cache to store tokens on a per- profile basis between runs.
Types ¶
type AuthorizationCodeHandler ¶
type AuthorizationCodeHandler struct{}
AuthorizationCodeHandler sets up the OAuth 2.0 authorization code with PKCE authentication flow.
func (*AuthorizationCodeHandler) OnRequest ¶
func (h *AuthorizationCodeHandler) OnRequest(request *http.Request, key string, params map[string]string) error
OnRequest gets run before the request goes out on the wire.
func (*AuthorizationCodeHandler) Parameters ¶
func (h *AuthorizationCodeHandler) Parameters() []cli.AuthParam
Parameters returns a list of OAuth2 Authorization Code inputs.
type AuthorizationCodeTokenSource ¶
type AuthorizationCodeTokenSource struct { ClientID string ClientSecret string AuthorizeURL string TokenURL string RedirectURL string EndpointParams *url.Values Scopes []string }
AuthorizationCodeTokenSource with PKCE as described in: https://www.oauth.com/oauth2-servers/pkce/ This works by running a local HTTP server on port 8484 and then having the user log in through a web browser, which redirects to the redirect url with an authorization code. That code is then used to make another HTTP request to fetch an auth token (and refresh token). That token is then in turn used to make requests against the API.
type ClientCredentialsHandler ¶
type ClientCredentialsHandler struct{}
ClientCredentialsHandler implements the Client Credentials OAuth2 flow.
func (*ClientCredentialsHandler) OnRequest ¶
func (h *ClientCredentialsHandler) OnRequest(request *http.Request, key string, params map[string]string) error
OnRequest gets run before the request goes out on the wire.
func (*ClientCredentialsHandler) Parameters ¶
func (h *ClientCredentialsHandler) Parameters() []cli.AuthParam
Parameters returns a list of OAuth2 Authorization Code inputs.
type RefreshTokenSource ¶
type RefreshTokenSource struct { // ClientID of the application ClientID string // TokenURL is used to fetch new tokens TokenURL string // EndpointParams are extra URL query parameters to include in the request EndpointParams *url.Values // RefreshToken from a cache, if available. If not, then the first time a // token is requested it will be loaded from the token source and this value // will get updated if it's present in the returned token. RefreshToken string // TokenSource to wrap to fetch new tokens if the refresh token is missing or // did not work to get a new token. TokenSource oauth2.TokenSource }
RefreshTokenSource will use a refresh token to try and get a new token before calling the original token source to get a new token.