feat(slack): use oauth2 authentication flow
This commit is contained in:
@@ -1,10 +1,21 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
if (requestConfig.headers && $.auth.data?.accessToken) {
|
||||
requestConfig.headers.Authorization = `Bearer ${$.auth.data.accessToken}`;
|
||||
const authData = $.auth.data;
|
||||
if (
|
||||
requestConfig.headers
|
||||
&& authData?.userAccessToken
|
||||
&& authData?.botAccessToken
|
||||
) {
|
||||
if (requestConfig.additionalProperties?.sendAsBot) {
|
||||
requestConfig.headers.Authorization = `Bearer ${authData.botAccessToken}`;
|
||||
} else {
|
||||
requestConfig.headers.Authorization = `Bearer ${authData.userAccessToken}`;
|
||||
}
|
||||
}
|
||||
|
||||
requestConfig.headers['Content-Type'] = requestConfig.headers['Content-Type'] || 'application/json; charset=utf-8';
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user