diff options
Diffstat (limited to 'vendor/github.com/nlopes/slack/oauth.go')
-rw-r--r-- | vendor/github.com/nlopes/slack/oauth.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/vendor/github.com/nlopes/slack/oauth.go b/vendor/github.com/nlopes/slack/oauth.go index 1285abbd..db10aa1b 100644 --- a/vendor/github.com/nlopes/slack/oauth.go +++ b/vendor/github.com/nlopes/slack/oauth.go @@ -1,6 +1,7 @@ package slack import ( + "context" "errors" "net/url" ) @@ -30,7 +31,12 @@ type OAuthResponse struct { // GetOAuthToken retrieves an AccessToken func GetOAuthToken(clientID, clientSecret, code, redirectURI string, debug bool) (accessToken string, scope string, err error) { - response, err := GetOAuthResponse(clientID, clientSecret, code, redirectURI, debug) + return GetOAuthTokenContext(context.Background(), clientID, clientSecret, code, redirectURI, debug) +} + +// 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) if err != nil { return "", "", err } @@ -38,6 +44,10 @@ func GetOAuthToken(clientID, clientSecret, code, redirectURI string, debug bool) } func GetOAuthResponse(clientID, clientSecret, code, redirectURI string, debug bool) (resp *OAuthResponse, err error) { + return GetOAuthResponseContext(context.Background(), clientID, clientSecret, code, redirectURI, debug) +} + +func GetOAuthResponseContext(ctx context.Context, clientID, clientSecret, code, redirectURI string, debug bool) (resp *OAuthResponse, err error) { values := url.Values{ "client_id": {clientID}, "client_secret": {clientSecret}, @@ -45,7 +55,7 @@ func GetOAuthResponse(clientID, clientSecret, code, redirectURI string, debug bo "redirect_uri": {redirectURI}, } response := &OAuthResponse{} - err = post("oauth.access", values, response, debug) + err = post(ctx, "oauth.access", values, response, debug) if err != nil { return nil, err } |