summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/slack-go/slack/oauth.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-03-28 23:50:47 +0100
committerGitHub <noreply@github.com>2020-03-28 23:50:47 +0100
commit092ca1cd678c44fa078bba11d4d219e61498342a (patch)
tree33be668a72610bfa9825817eb84017fdad8b362a /vendor/github.com/slack-go/slack/oauth.go
parent0df253964123537b91e5a7364c83cc52f0e88df4 (diff)
downloadmatterbridge-msglm-092ca1cd678c44fa078bba11d4d219e61498342a.tar.gz
matterbridge-msglm-092ca1cd678c44fa078bba11d4d219e61498342a.tar.bz2
matterbridge-msglm-092ca1cd678c44fa078bba11d4d219e61498342a.zip
Update vendor slack-go/slack (#1068)
Diffstat (limited to 'vendor/github.com/slack-go/slack/oauth.go')
-rw-r--r--vendor/github.com/slack-go/slack/oauth.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/github.com/slack-go/slack/oauth.go b/vendor/github.com/slack-go/slack/oauth.go
index 29d6dce9..64118fb0 100644
--- a/vendor/github.com/slack-go/slack/oauth.go
+++ b/vendor/github.com/slack-go/slack/oauth.go
@@ -31,6 +31,40 @@ type OAuthResponse struct {
SlackResponse
}
+// OAuthV2Response ...
+type OAuthV2Response struct {
+ AccessToken string `json:"access_token"`
+ TokenType string `json:"token_type"`
+ Scope string `json:"scope"`
+ BotUserID string `json:"bot_user_id"`
+ AppID string `json:"app_id"`
+ TeamID string `json:"team_id"`
+ Team OAuthV2ResponseTeam `json:"team"`
+ Enterprise OAuthV2ResponseEnterprise `json:"enterprise"`
+ AuthedUser OAuthV2ResponseAuthedUser `json:"authed_user"`
+ SlackResponse
+}
+
+// OAuthV2ResponseTeam ...
+type OAuthV2ResponseTeam struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+}
+
+// OAuthV2ResponseEnterprise ...
+type OAuthV2ResponseEnterprise struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+}
+
+// OAuthV2ResponseAuthedUser ...
+type OAuthV2ResponseAuthedUser struct {
+ ID string `json:"id"`
+ Scope string `json:"scope"`
+ AccessToken string `json:"access_token"`
+ TokenType string `json:"token_type"`
+}
+
// GetOAuthToken retrieves an AccessToken
func GetOAuthToken(client httpClient, clientID, clientSecret, code, redirectURI string) (accessToken string, scope string, err error) {
return GetOAuthTokenContext(context.Background(), client, clientID, clientSecret, code, redirectURI)
@@ -62,3 +96,23 @@ func GetOAuthResponseContext(ctx context.Context, client httpClient, clientID, c
}
return response, response.Err()
}
+
+// GetOAuthV2Response gets a V2 OAuth access token response - https://api.slack.com/methods/oauth.v2.access
+func GetOAuthV2Response(client httpClient, clientID, clientSecret, code, redirectURI string) (resp *OAuthV2Response, err error) {
+ return GetOAuthV2ResponseContext(context.Background(), client, clientID, clientSecret, code, redirectURI)
+}
+
+// GetOAuthV2ResponseContext with a context, gets a V2 OAuth access token response
+func GetOAuthV2ResponseContext(ctx context.Context, client httpClient, clientID, clientSecret, code, redirectURI string) (resp *OAuthV2Response, err error) {
+ values := url.Values{
+ "client_id": {clientID},
+ "client_secret": {clientSecret},
+ "code": {code},
+ "redirect_uri": {redirectURI},
+ }
+ response := &OAuthV2Response{}
+ if err = postForm(ctx, client, APIURL+"oauth.v2.access", values, response, discard{}); err != nil {
+ return nil, err
+ }
+ return response, response.Err()
+}