@@ -266,7 +266,13 @@ func (s *Server) authorizeOAuthApp(apiContext api.Context) error {
266
266
// Slack is annoying and makes us call this query parameter user_scope instead of scope.
267
267
// user_scope is used for delegated user permissions (which is what we want), while just scope is used for bot permissions.
268
268
if app .Spec .Manifest .Type == types2 .OAuthAppTypeSlack {
269
- q .Set ("user_scope" , scope )
269
+ if scope != "" {
270
+ q .Set ("scope" , scope )
271
+ }
272
+ userScope := apiContext .URL .Query ().Get ("user_scope" )
273
+ if userScope != "" {
274
+ q .Set ("user_scope" , userScope )
275
+ }
270
276
} else {
271
277
q .Set ("scope" , scope )
272
278
}
@@ -431,12 +437,18 @@ func (s *Server) callbackOAuthApp(apiContext api.Context) error {
431
437
}
432
438
433
439
tokenResp = & types.OAuthTokenResponse {
434
- State : state ,
435
- Scope : slackTokenResp .AuthedUser .Scope ,
436
- AccessToken : slackTokenResp .AuthedUser .AccessToken ,
437
- Ok : slackTokenResp .Ok ,
438
- Error : slackTokenResp .Error ,
439
- CreatedAt : time .Now (),
440
+ State : state ,
441
+ Ok : slackTokenResp .Ok ,
442
+ Error : slackTokenResp .Error ,
443
+ CreatedAt : time .Now (),
444
+ }
445
+
446
+ if slackTokenResp .AuthedUser .AccessToken != "" {
447
+ tokenResp .AccessToken = slackTokenResp .AuthedUser .AccessToken
448
+ tokenResp .Scope = slackTokenResp .AuthedUser .Scope
449
+ } else if slackTokenResp .AccessToken != "" {
450
+ tokenResp .AccessToken = slackTokenResp .AccessToken
451
+ tokenResp .Scope = slackTokenResp .Scope
440
452
}
441
453
case types2 .OAuthAppTypeGitHub :
442
454
// Read the response body
0 commit comments