-
Notifications
You must be signed in to change notification settings - Fork 1
/
authentication.js
46 lines (42 loc) · 1.24 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
const zapier = require('zapier-platform-core');
zapier.tools.env.inject();
/**
* This function will try to get the user profile. It will look at the status
* code of the response. If it is a 401 or 403 it is rejected.
* Otherwise we just assume it succeeded.
*
* @param z The Z object.
* @param bundle An object containing metadata and auth data.
* @returns {Promise<T | never>}
*/
const test = (z, bundle) => z.request({
url: `${process.env.PLATFORM_URL}/api/permission/systemuser/profile/`,
}).then(response => response);
/**
* See: https://zapier.github.io/zapier-platform-cli/#authentication
* Remember this is config code and as such ${process.env.*} will come from
* your local .env file
* @TODO: INT-9 get environment expansion working.
*/
const authentication = {
type: 'custom',
fields: [
{
key: 'email',
label: 'Email address',
helpText: 'The email address to log in.',
required: true,
type: 'string',
},
{
key: 'token',
label: 'API Token',
helpText: `You can find the API token here: ${process.env.PLATFORM_URL}/user/personal_settings/`,
required: true,
type: 'string',
},
],
test,
connectionLabel: () => '{{email}}',
};
module.exports = authentication;