| 1 | package slackscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/ |
| 2 | |
| 3 | import ( |
| 4 | "contextscip-go gomod github.com/golang/go/src go1.16 context/" |
| 5 | "net/urlscip-go gomod github.com/golang/go/src go1.16 `net/url`/" |
| 6 | ) |
| 7 | |
| 8 | // OAuthResponseIncomingWebhook ... |
| 9 | type OAuthResponseIncomingWebhookscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponseIncomingWebhook# struct { |
| 10 | URLscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponseIncomingWebhook#URL. string `json:"url"` |
| 11 | Channelscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponseIncomingWebhook#Channel. string `json:"channel"` |
| 12 | ChannelIDscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponseIncomingWebhook#ChannelID. string `json:"channel_id,omitempty"` |
| 13 | ConfigurationURLscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponseIncomingWebhook#ConfigurationURL. string `json:"configuration_url"` |
| 14 | } |
| 15 | |
| 16 | // OAuthResponseBot ... |
| 17 | type OAuthResponseBotscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponseBot# struct { |
| 18 | BotUserIDscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponseBot#BotUserID. string `json:"bot_user_id"` |
| 19 | BotAccessTokenscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponseBot#BotAccessToken. string `json:"bot_access_token"` |
| 20 | } |
| 21 | |
| 22 | // OAuthResponse ... |
| 23 | type OAuthResponsescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse# struct { |
| 24 | AccessTokenscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#AccessToken. string `json:"access_token"` |
| 25 | Scopescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#Scope. string `json:"scope"` |
| 26 | TeamNamescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#TeamName. string `json:"team_name"` |
| 27 | TeamIDscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#TeamID. string `json:"team_id"` |
| 28 | IncomingWebhookscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#IncomingWebhook. OAuthResponseIncomingWebhookscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponseIncomingWebhook# `json:"incoming_webhook"` |
| 29 | Botscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#Bot. OAuthResponseBotscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponseBot# `json:"bot"` |
| 30 | UserIDscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#UserID. string `json:"user_id,omitempty"` |
| 31 | SlackResponsescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#SlackResponse. |
| 32 | } |
| 33 | |
| 34 | // OAuthV2Response ... |
| 35 | type OAuthV2Responsescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response# struct { |
| 36 | AccessTokenscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#AccessToken. string `json:"access_token"` |
| 37 | TokenTypescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#TokenType. string `json:"token_type"` |
| 38 | Scopescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#Scope. string `json:"scope"` |
| 39 | BotUserIDscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#BotUserID. string `json:"bot_user_id"` |
| 40 | AppIDscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#AppID. string `json:"app_id"` |
| 41 | Teamscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#Team. OAuthV2ResponseTeamscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseTeam# `json:"team"` |
| 42 | IncomingWebhookscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#IncomingWebhook. OAuthResponseIncomingWebhookscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponseIncomingWebhook# `json:"incoming_webhook"` |
| 43 | Enterprisescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#Enterprise. OAuthV2ResponseEnterprisescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseEnterprise# `json:"enterprise"` |
| 44 | AuthedUserscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#AuthedUser. OAuthV2ResponseAuthedUserscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseAuthedUser# `json:"authed_user"` |
| 45 | RefreshTokenscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#RefreshToken. string `json:"refresh_token"` |
| 46 | ExpiresInscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#ExpiresIn. int `json:"expires_in"` |
| 47 | SlackResponsescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#SlackResponse. |
| 48 | } |
| 49 | |
| 50 | // OAuthV2ResponseTeam ... |
| 51 | type OAuthV2ResponseTeamscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseTeam# struct { |
| 52 | IDscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseTeam#ID. string `json:"id"` |
| 53 | Namescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseTeam#Name. string `json:"name"` |
| 54 | } |
| 55 | |
| 56 | // OAuthV2ResponseEnterprise ... |
| 57 | type OAuthV2ResponseEnterprisescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseEnterprise# struct { |
| 58 | IDscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseEnterprise#ID. string `json:"id"` |
| 59 | Namescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseEnterprise#Name. string `json:"name"` |
| 60 | } |
| 61 | |
| 62 | // OAuthV2ResponseAuthedUser ... |
| 63 | type OAuthV2ResponseAuthedUserscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseAuthedUser# struct { |
| 64 | IDscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseAuthedUser#ID. string `json:"id"` |
| 65 | Scopescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseAuthedUser#Scope. string `json:"scope"` |
| 66 | AccessTokenscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseAuthedUser#AccessToken. string `json:"access_token"` |
| 67 | ExpiresInscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseAuthedUser#ExpiresIn. int `json:"expires_in"` |
| 68 | RefreshTokenscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseAuthedUser#RefreshToken. string `json:"refresh_token"` |
| 69 | TokenTypescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2ResponseAuthedUser#TokenType. string `json:"token_type"` |
| 70 | } |
| 71 | |
| 72 | // GetOAuthToken retrieves an AccessToken |
| 73 | func GetOAuthTokenscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/GetOAuthToken().(client httpClientscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/httpClient#, clientID, clientSecret, code, redirectURI string) (accessToken string, scope string, err error) { |
| 74 | return GetOAuthTokenContextscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/GetOAuthTokenContext().(contextscip-go gomod github.com/golang/go/src go1.16 context/.Backgroundscip-go gomod github.com/golang/go/src go1.16 context/Background().(), client, clientID, clientSecret, code, redirectURI) |
| 75 | } |
| 76 | |
| 77 | // GetOAuthTokenContext retrieves an AccessToken with a custom context |
| 78 | func GetOAuthTokenContextscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/GetOAuthTokenContext().(ctx contextscip-go gomod github.com/golang/go/src go1.16 context/.Contextscip-go gomod github.com/golang/go/src go1.16 context/Context#, client httpClientscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/httpClient#, clientID, clientSecret, code, redirectURI string) (accessToken string, scope string, err error) { |
| 79 | response, err := GetOAuthResponseContextscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/GetOAuthResponseContext().(ctx, client, clientID, clientSecret, code, redirectURI) |
| 80 | if err != nil { |
| 81 | return "", "", err |
| 82 | } |
| 83 | return response.AccessTokenscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#AccessToken., response.Scopescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#Scope., nil |
| 84 | } |
| 85 | |
| 86 | // GetBotOAuthToken retrieves top-level and bot AccessToken - https://api.slack.com/legacy/oauth#bot_user_access_tokens |
| 87 | func GetBotOAuthTokenscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/GetBotOAuthToken().(client httpClientscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/httpClient#, clientID, clientSecret, code, redirectURI string) (accessToken string, scope string, bot OAuthResponseBotscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponseBot#, err error) { |
| 88 | return GetBotOAuthTokenContextscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/GetBotOAuthTokenContext().(contextscip-go gomod github.com/golang/go/src go1.16 context/.Backgroundscip-go gomod github.com/golang/go/src go1.16 context/Background().(), client, clientID, clientSecret, code, redirectURI) |
| 89 | } |
| 90 | |
| 91 | // GetBotOAuthTokenContext retrieves top-level and bot AccessToken with a custom context |
| 92 | func GetBotOAuthTokenContextscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/GetBotOAuthTokenContext().(ctx contextscip-go gomod github.com/golang/go/src go1.16 context/.Contextscip-go gomod github.com/golang/go/src go1.16 context/Context#, client httpClientscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/httpClient#, clientID, clientSecret, code, redirectURI string) (accessToken string, scope string, bot OAuthResponseBotscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponseBot#, err error) { |
| 93 | response, err := GetOAuthResponseContextscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/GetOAuthResponseContext().(ctx, client, clientID, clientSecret, code, redirectURI) |
| 94 | if err != nil { |
| 95 | return "", "", OAuthResponseBotscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponseBot#{}, err |
| 96 | } |
| 97 | return response.AccessTokenscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#AccessToken., response.Scopescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#Scope., response.Botscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#Bot., nil |
| 98 | } |
| 99 | |
| 100 | // GetOAuthResponse retrieves OAuth response |
| 101 | func GetOAuthResponsescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/GetOAuthResponse().(client httpClientscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/httpClient#, clientID, clientSecret, code, redirectURI string) (resp *OAuthResponsescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#, err error) { |
| 102 | return GetOAuthResponseContextscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/GetOAuthResponseContext().(contextscip-go gomod github.com/golang/go/src go1.16 context/.Backgroundscip-go gomod github.com/golang/go/src go1.16 context/Background().(), client, clientID, clientSecret, code, redirectURI) |
| 103 | } |
| 104 | |
| 105 | // GetOAuthResponseContext retrieves OAuth response with custom context |
| 106 | func GetOAuthResponseContextscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/GetOAuthResponseContext().(ctx contextscip-go gomod github.com/golang/go/src go1.16 context/.Contextscip-go gomod github.com/golang/go/src go1.16 context/Context#, client httpClientscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/httpClient#, clientID, clientSecret, code, redirectURI string) (resp *OAuthResponsescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#, err error) { |
| 107 | values := urlscip-go gomod github.com/golang/go/src go1.16 `net/url`/.Valuesscip-go gomod github.com/golang/go/src go1.16 `net/url`/Values#{ |
| 108 | "client_id": {clientID}, |
| 109 | "client_secret": {clientSecret}, |
| 110 | "code": {code}, |
| 111 | "redirect_uri": {redirectURI}, |
| 112 | } |
| 113 | response := &OAuthResponsescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthResponse#{} |
| 114 | if err = postFormscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/postForm().(ctx, client, APIURLscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/APIURL.+"oauth.access", values, response, discardscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/discard#{}); err != nil { |
| 115 | return nil, err |
| 116 | } |
| 117 | return response, response.Errscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/SlackResponse#Err().() |
| 118 | } |
| 119 | |
| 120 | // GetOAuthV2Response gets a V2 OAuth access token response - https://api.slack.com/methods/oauth.v2.access |
| 121 | func GetOAuthV2Responsescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/GetOAuthV2Response().(client httpClientscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/httpClient#, clientID, clientSecret, code, redirectURI string) (resp *OAuthV2Responsescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#, err error) { |
| 122 | return GetOAuthV2ResponseContextscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/GetOAuthV2ResponseContext().(contextscip-go gomod github.com/golang/go/src go1.16 context/.Backgroundscip-go gomod github.com/golang/go/src go1.16 context/Background().(), client, clientID, clientSecret, code, redirectURI) |
| 123 | } |
| 124 | |
| 125 | // GetOAuthV2ResponseContext with a context, gets a V2 OAuth access token response |
| 126 | func GetOAuthV2ResponseContextscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/GetOAuthV2ResponseContext().(ctx contextscip-go gomod github.com/golang/go/src go1.16 context/.Contextscip-go gomod github.com/golang/go/src go1.16 context/Context#, client httpClientscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/httpClient#, clientID, clientSecret, code, redirectURI string) (resp *OAuthV2Responsescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#, err error) { |
| 127 | values := urlscip-go gomod github.com/golang/go/src go1.16 `net/url`/.Valuesscip-go gomod github.com/golang/go/src go1.16 `net/url`/Values#{ |
| 128 | "client_id": {clientID}, |
| 129 | "client_secret": {clientSecret}, |
| 130 | "code": {code}, |
| 131 | "redirect_uri": {redirectURI}, |
| 132 | } |
| 133 | response := &OAuthV2Responsescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#{} |
| 134 | if err = postFormscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/postForm().(ctx, client, APIURLscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/APIURL.+"oauth.v2.access", values, response, discardscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/discard#{}); err != nil { |
| 135 | return nil, err |
| 136 | } |
| 137 | return response, response.Errscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/SlackResponse#Err().() |
| 138 | } |
| 139 | |
| 140 | // RefreshOAuthV2AccessContext with a context, gets a V2 OAuth access token response |
| 141 | func RefreshOAuthV2Tokenscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/RefreshOAuthV2Token().(client httpClientscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/httpClient#, clientID, clientSecret, refreshToken string) (resp *OAuthV2Responsescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#, err error) { |
| 142 | return RefreshOAuthV2TokenContextscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/RefreshOAuthV2TokenContext().(contextscip-go gomod github.com/golang/go/src go1.16 context/.Backgroundscip-go gomod github.com/golang/go/src go1.16 context/Background().(), client, clientID, clientSecret, refreshToken) |
| 143 | } |
| 144 | |
| 145 | // RefreshOAuthV2AccessContext with a context, gets a V2 OAuth access token response |
| 146 | func RefreshOAuthV2TokenContextscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/RefreshOAuthV2TokenContext().(ctx contextscip-go gomod github.com/golang/go/src go1.16 context/.Contextscip-go gomod github.com/golang/go/src go1.16 context/Context#, client httpClientscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/httpClient#, clientID, clientSecret, refreshToken string) (resp *OAuthV2Responsescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#, err error) { |
| 147 | values := urlscip-go gomod github.com/golang/go/src go1.16 `net/url`/.Valuesscip-go gomod github.com/golang/go/src go1.16 `net/url`/Values#{ |
| 148 | "client_id": {clientID}, |
| 149 | "client_secret": {clientSecret}, |
| 150 | "refresh_token": {refreshToken}, |
| 151 | "grant_type": {"refresh_token"}, |
| 152 | } |
| 153 | response := &OAuthV2Responsescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OAuthV2Response#{} |
| 154 | if err = postFormscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/postForm().(ctx, client, APIURLscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/APIURL.+"oauth.v2.access", values, response, discardscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/discard#{}); err != nil { |
| 155 | return nil, err |
| 156 | } |
| 157 | return response, response.Errscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/SlackResponse#Err().() |
| 158 | } |