-
Notifications
You must be signed in to change notification settings - Fork 190
/
Copy pathAuthenticationOAuth2ConfigSchema.js
73 lines (70 loc) · 2.31 KB
/
AuthenticationOAuth2ConfigSchema.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'use strict';
const makeSchema = require('../utils/makeSchema');
const FunctionSchema = require('./FunctionSchema');
const RedirectRequestSchema = require('./RedirectRequestSchema');
const RequestSchema = require('./RequestSchema');
module.exports = makeSchema(
{
id: '/AuthenticationOAuth2ConfigSchema',
description: 'Config for OAuth2 authentication.',
type: 'object',
required: ['authorizeUrl', 'getAccessToken'],
properties: {
authorizeUrl: {
description:
'Define where Zapier will redirect the user to authorize our app. Note: we append the redirect URL and state parameters to return value of this function.',
oneOf: [
{ $ref: RedirectRequestSchema.id },
{ $ref: FunctionSchema.id },
],
},
getAccessToken: {
description: 'Define how Zapier fetches an access token from the API',
oneOf: [{ $ref: RequestSchema.id }, { $ref: FunctionSchema.id }],
},
refreshAccessToken: {
description:
'Define how Zapier will refresh the access token from the API',
oneOf: [{ $ref: RequestSchema.id }, { $ref: FunctionSchema.id }],
},
codeParam: {
description:
'Define a non-standard code param Zapier should scrape instead.',
type: 'string',
},
scope: {
description: 'What scope should Zapier request?',
type: 'string',
},
autoRefresh: {
description:
'Should Zapier invoke `refreshAccessToken` when we receive an error for a 401 response?',
type: 'boolean',
},
},
additionalProperties: false,
examples: [
{
authorizeUrl: { require: 'some/path/to/file.js' },
getAccessToken: { require: 'some/path/to/file2.js' },
},
{
authorizeUrl: { require: 'some/path/to/file.js' },
getAccessToken: { require: 'some/path/to/file2.js' },
refreshAccessToken: { require: 'some/path/to/file3.js' },
codeParam: 'unique_code',
scope: 'read/write',
autoRefresh: true,
},
],
antiExamples: [
{
example: {
authorizeUrl: { require: 'some/path/to/file.js' },
},
reason: 'Missing required key getAccessToken.',
},
],
},
[FunctionSchema, RedirectRequestSchema, RequestSchema]
);