-
Notifications
You must be signed in to change notification settings - Fork 0
/
authentication.js
53 lines (45 loc) · 1.32 KB
/
authentication.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const test = (z, bundle) => {
return z.request({
url: bundle.authData.baseUrl + '/civicrm/zapierauth?apiKey=' + bundle.authData.api_key + '&key=' + bundle.authData.key,
}).then((response) => {
return response;
});
};
module.exports = {
type: 'custom',
fields: [
{
key: 'baseUrl',
type: 'string',
required: true,
helpText: 'The base URL for the API. eg https://example.com',
},
{
key: 'api_key',
type: 'string',
required: true,
helpText: 'API of user 1. You can use the extension https://civicrm.org/extensions/api-key to create/view API key of any user',
},
{
key: 'key',
type: 'string',
required: true,
helpText: 'Site Key found in civicrm.settings.php. For more information, see https://docs.civicrm.org/sysadmin/en/latest/setup/secret-keys/#civicrm_site_key',
},
],
test: test,
};
// const addApiKeyToHeader = (request, z, bundle) => {
// request.headers['X-baseUrl'] = bundle.authData.baseUrl;
// const basicHash = Buffer.from(`${bundle.authData.api_key}:x`).toString(
// 'base64'
// );
// request.headers.Authorization = `Basic ${basicHash}`;
// return request;
// };
// const App = {
// // ...
// authentication: authentication,
// // beforeRequest: [addApiKeyToHeader],
// // ...
// };