summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nlopes/slack/oauth.go
diff options
context:
space:
mode:
authorPatrick Connolly <patrick.c.connolly@gmail.com>2018-12-02 02:55:35 +0800
committerWim <wim@42.be>2018-12-01 19:55:35 +0100
commite538a4d30459e9da1a021400b5de85894b4efabc (patch)
treeead4f82d5459fe0d3465f7e3656243cd613c07a6 /vendor/github.com/nlopes/slack/oauth.go
parentf94c2b40a3e8eb45054bda1b71eb6fd3f9bc9e6d (diff)
downloadmatterbridge-msglm-e538a4d30459e9da1a021400b5de85894b4efabc.tar.gz
matterbridge-msglm-e538a4d30459e9da1a021400b5de85894b4efabc.tar.bz2
matterbridge-msglm-e538a4d30459e9da1a021400b5de85894b4efabc.zip
Update nlopes/slack to 4.1-dev (#595)
Diffstat (limited to 'vendor/github.com/nlopes/slack/oauth.go')
-rw-r--r--vendor/github.com/nlopes/slack/oauth.go26
1 files changed, 12 insertions, 14 deletions
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()
}