feat(salesforce): add authentication

This commit is contained in:
Ali BARIN
2022-11-03 23:08:28 +01:00
parent 7d82ca5d3c
commit ede55a70aa
9 changed files with 289 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
import { TBeforeRequest } from '@automatisch/types';
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
const { instanceUrl, tokenType, accessToken } = $.auth.data;
if (instanceUrl) {
requestConfig.baseURL = instanceUrl as string;
}
if (tokenType && accessToken) {
requestConfig.headers.Authorization = `${tokenType} ${accessToken}`;
}
return requestConfig;
};
export default addAuthHeader;

View File

@@ -0,0 +1,10 @@
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
const getCurrentUser = async ($: IGlobalVariable): Promise<IJSONObject> => {
const response = await $.http.get('/services/data/v55.0/chatter/users/me');
const currentUser = response.data;
return currentUser;
};
export default getCurrentUser;