From e538a4d30459e9da1a021400b5de85894b4efabc Mon Sep 17 00:00:00 2001 From: Patrick Connolly Date: Sun, 2 Dec 2018 02:55:35 +0800 Subject: Update nlopes/slack to 4.1-dev (#595) --- vendor/github.com/nlopes/slack/oauth.go | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'vendor/github.com/nlopes/slack/oauth.go') diff --git a/vendor/github.com/nlopes/slack/oauth.go b/vendor/github.com/nlopes/slack/oauth.go index 378af4a5..8a8194cb 100644 --- a/vendor/github.com/nlopes/slack/oauth.go +++ b/vendor/github.com/nlopes/slack/oauth.go @@ -2,10 +2,10 @@ package slack import ( "context" - "errors" "net/url" ) +// OAuthResponseIncomingWebhook ... type OAuthResponseIncomingWebhook struct { URL string `json:"url"` Channel string `json:"channel"` @@ -13,11 +13,13 @@ type OAuthResponseIncomingWebhook struct { ConfigurationURL string `json:"configuration_url"` } +// OAuthResponseBot ... type OAuthResponseBot struct { BotUserID string `json:"bot_user_id"` BotAccessToken string `json:"bot_access_token"` } +// OAuthResponse ... type OAuthResponse struct { AccessToken string `json:"access_token"` Scope string `json:"scope"` @@ -30,24 +32,24 @@ type OAuthResponse struct { } // GetOAuthToken retrieves an AccessToken -func GetOAuthToken(clientID, clientSecret, code, redirectURI string, debug bool) (accessToken string, scope string, err error) { - return GetOAuthTokenContext(context.Background(), clientID, clientSecret, code, redirectURI, debug) +func GetOAuthToken(client httpClient, clientID, clientSecret, code, redirectURI string) (accessToken string, scope string, err error) { + return GetOAuthTokenContext(context.Background(), client, clientID, clientSecret, code, redirectURI) } // GetOAuthTokenContext retrieves an AccessToken with a custom context -func GetOAuthTokenContext(ctx context.Context, clientID, clientSecret, code, redirectURI string, debug bool) (accessToken string, scope string, err error) { - response, err := GetOAuthResponseContext(ctx, clientID, clientSecret, code, redirectURI, debug) +func GetOAuthTokenContext(ctx context.Context, client httpClient, clientID, clientSecret, code, redirectURI string) (accessToken string, scope string, err error) { + response, err := GetOAuthResponseContext(ctx, client, clientID, clientSecret, code, redirectURI) if err != nil { return "", "", err } return response.AccessToken, response.Scope, nil } -func GetOAuthResponse(clientID, clientSecret, code, redirectURI string, debug bool) (resp *OAuthResponse, err error) { - return GetOAuthResponseContext(context.Background(), clientID, clientSecret, code, redirectURI, debug) +func GetOAuthResponse(client httpClient, clientID, clientSecret, code, redirectURI string) (resp *OAuthResponse, err error) { + return GetOAuthResponseContext(context.Background(), client, clientID, clientSecret, code, redirectURI) } -func GetOAuthResponseContext(ctx context.Context, clientID, clientSecret, code, redirectURI string, debug bool) (resp *OAuthResponse, err error) { +func GetOAuthResponseContext(ctx context.Context, client httpClient, clientID, clientSecret, code, redirectURI string) (resp *OAuthResponse, err error) { values := url.Values{ "client_id": {clientID}, "client_secret": {clientSecret}, @@ -55,12 +57,8 @@ func GetOAuthResponseContext(ctx context.Context, clientID, clientSecret, code, "redirect_uri": {redirectURI}, } response := &OAuthResponse{} - err = postSlackMethod(ctx, customHTTPClient, "oauth.access", values, response, debug) - if err != nil { + if err = postSlackMethod(ctx, client, "oauth.access", values, response, discard{}); err != nil { return nil, err } - if !response.Ok { - return nil, errors.New(response.Error) - } - return response, nil + return response, response.Err() } -- cgit v1.2.3