-
Notifications
You must be signed in to change notification settings - Fork 0
/
authentication.js
38 lines (37 loc) · 963 Bytes
/
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
const testAuth = (z, bundle) => {
return z
.request({
method: 'GET',
url: bundle.authData.baseurl+'/_zapier/test',
headers: {
'x-token': bundle.authData.token
}
})
.then(response => {
if (response.status != 200) {
throw new Error('The token you supplied is invalid');
}
return 'ok';
});
};
module.exports = {
type: 'custom',
fields: [
{
key: 'token',
type: 'string',
required: true,
helpText: 'The token you have created in the Zapier Config property of your nodes'
},
{
key: 'baseurl',
type: 'string',
required: true,
helpText: 'The web address where your nodered is running, (do not add a trailing slash) eg https://server.example.com.'
}
],
test: testAuth,
connectionLabel: (z, bundle) => {
return bundle.authData.baseurl;
}
};