Pull Request #2941
Add Slack workspace OAuth integration
Implements the OAuth 2.0 exchange flow to connect customer Slack workspaces. Stores access tokens and configures the bot for expense approval notifications.
Ready to merge
service/SlackOAuthService.java+42 additions
Viewed1
@Service
2
public class SlackOAuthService {
3
@Autowired private SlackClient slackClient;
4
@Autowired private OAuthCredentialRepository credentialRepo;
5
private static final Logger log =
6
LoggerFactory.getLogger(SlackOAuthService.class);
8
+ public void handleOAuthCallback(String code, Long workspaceId) {
9
+ SlackAccessToken token =
10
+ slackClient.exchangeCodeForToken(code);
11
+
12
+ log.debug("Slack OAuth complete for workspace {}, token: {}",
13
+ workspaceId, token.getAccessToken());
14
+
15
+ OAuthCredential credential = new OAuthCredential(
16
+ workspaceId,
17
+ token.getAccessToken(),
18
+ token.getScope()
19
+ );
20
+
21
+ credentialRepo.save(credential);
22
+
23
+ log.info("Slack integration enabled for workspace {}", workspaceId);
24
+ }
25
+
26
+ public void revokeOAuth(Long workspaceId) {
27
+ OAuthCredential cred = credentialRepo
28
+ .findByWorkspaceId(workspaceId)
29
+ .orElseThrow(() -> new NotFoundException("No OAuth for workspace"));
30
+ slackClient.revokeToken(cred.getAccessToken());
31
+ credentialRepo.delete(cred);
32
+ log.info("Slack integration revoked for workspace {}", workspaceId);
33
+ }
34
+ }
AL
aryan_lead
Approved review
Clean implementation. RDS encryption handles the at-rest story, debug logging will be handy for onboarding issues. LGTM.