@@ -177,6 +177,74 @@ func RefreshOAuthV2TokenContext(ctx context.Context, client httpClient, clientID
177177 return response , response .Err ()
178178}
179179
180+ // OpenIDConnectUserInfoResponse contains the response from openid.connect.userInfo.
181+ //
182+ // Some of the fields in the response to this method are preceded with https://slack.com/.
183+ // These fields are Slack-specific, and they're from the perspective of Slack.
184+ type OpenIDConnectUserInfoResponse struct {
185+ Ok bool `json:"ok"`
186+
187+ Sub string `json:"sub"`
188+
189+ UserID string `json:"https://slack.com/user_id"`
190+ TeamID string `json:"https://slack.com/team_id"`
191+
192+ Email string `json:"email"`
193+ EmailVerified bool `json:"email_verified"`
194+ DateEmailVerified int64 `json:"date_email_verified"`
195+
196+ Name string `json:"name"`
197+ Picture string `json:"picture"`
198+ GivenName string `json:"given_name"`
199+ FamilyName string `json:"family_name"`
200+ Locale string `json:"locale"`
201+
202+ TeamName string `json:"https://slack.com/team_name"`
203+ TeamDomain string `json:"https://slack.com/team_domain"`
204+ TeamImage34 string `json:"https://slack.com/team_image_34"`
205+ TeamImage44 string `json:"https://slack.com/team_image_44"`
206+ TeamImage68 string `json:"https://slack.com/team_image_68"`
207+ TeamImage88 string `json:"https://slack.com/team_image_88"`
208+ TeamImage102 string `json:"https://slack.com/team_image_102"`
209+ TeamImage132 string `json:"https://slack.com/team_image_132"`
210+ TeamImage230 string `json:"https://slack.com/team_image_230"`
211+
212+ // `TeamImageDefault` indicates whether the image is a default one (true), or someone
213+ // uploaded their own (false).
214+ TeamImageDefault bool `json:"https://slack.com/team_image_default"`
215+
216+ UserImage24 string `json:"https://slack.com/user_image_24"`
217+ UserImage32 string `json:"https://slack.com/user_image_32"`
218+ UserImage48 string `json:"https://slack.com/user_image_48"`
219+ UserImage72 string `json:"https://slack.com/user_image_72"`
220+ UserImage192 string `json:"https://slack.com/user_image_192"`
221+ UserImage512 string `json:"https://slack.com/user_image_512"`
222+ UserImage1024 string `json:"https://slack.com/user_image_1024"`
223+ UserImageOriginal string `json:"https://slack.com/user_image_original"`
224+
225+ SlackResponse
226+ }
227+
228+ // GetOpenIDConnectUserInfo returns the user info for the token.
229+ // For more details, see GetOpenIDConnectUserInfoContext documentation.
230+ func (api * Client ) GetOpenIDConnectUserInfo () (* OpenIDConnectUserInfoResponse , error ) {
231+ return api .GetOpenIDConnectUserInfoContext (context .Background ())
232+ }
233+
234+ // GetOpenIDConnectUserInfoContext returns identity information about the user associated with the token.
235+ // Slack API docs: https://docs.slack.dev/reference/methods/openid.connect.userInfo
236+ func (api * Client ) GetOpenIDConnectUserInfoContext (ctx context.Context ) (* OpenIDConnectUserInfoResponse , error ) {
237+ values := url.Values {
238+ "token" : {api .token },
239+ }
240+ response := & OpenIDConnectUserInfoResponse {}
241+ err := api .postMethod (ctx , "openid.connect.userInfo" , values , response )
242+ if err != nil {
243+ return nil , err
244+ }
245+ return response , response .Err ()
246+ }
247+
180248// GetOpenIDConnectToken exchanges a temporary OAuth verifier code for an access token for Sign in with Slack.
181249// For more details, see GetOpenIDConnectTokenContext documentation.
182250func GetOpenIDConnectToken (client httpClient , clientID , clientSecret , code , redirectURI string ) (resp * OpenIDConnectResponse , err error ) {
0 commit comments