Skip to content

Commit

Permalink
calendly (major update) Authorization updated from ApiKey to Oauth2 (#…
Browse files Browse the repository at this point in the history
…209)

* Calendly oauth updated from ApiKey to Oauth2

* bundle.json

* lint
  • Loading branch information
sayam-nasir authored Oct 10, 2024
1 parent cd43710 commit b3e65fc
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 23 deletions.
28 changes: 12 additions & 16 deletions src/appmixer/calendly/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,31 @@

module.exports = {

type: 'apiKey',
type: 'oauth2',

definition: {

accountNameFromProfileInfo: 'data.attributes.email',
accountNameFromProfileInfo: 'resource.email',

auth: {
apiKey: {
type: 'text',
name: 'API Key',
tooltip: 'Log into your calendly account and find <i>integration</i> page in settings. ' +
'<br/>You have to have Premium or Pro Calendly subscription in order make Calendly components work. ' +
'<br/>It also works with free 14 days trial.'
}
},
authUrl: 'https://auth.calendly.com/oauth/authorize',

requestAccessToken: 'https://auth.calendly.com/oauth/token',

requestProfileInfo: {
method: 'GET',
url: 'https://calendly.com/api/v1/users/me',
url: 'https://api.calendly.com/users/me',
headers: {
'X-TOKEN': '{{apiKey}}'
'Authorization': 'Bearer {{accessToken}}'
}
},

validate: {
refreshAccessToken: 'https://auth.calendly.com/oauth/token',

validateAccessToken: {
method: 'GET',
url: 'https://calendly.com/api/v1/users/me',
url: 'https://api.calendly.com/users/me',
headers: {
'X-TOKEN': '{{apiKey}}'
'Authorization': 'Bearer {{accessToken}}'
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/appmixer/calendly/bundle.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"name": "appmixer.calendly",
"version": "1.0.2",
"version": "1.0.3",
"changelog": {
"1.0.1": [
"Initial version"
],
"1.0.2": [
"Provide friendly access to first 3 answers of custom questions."
],
"1.0.3": [
"Breaking Change: Updated authorization to Oauth2"
]
}
}
4 changes: 2 additions & 2 deletions src/appmixer/calendly/calendly-commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
method: 'POST',
url: 'https://calendly.com/api/v1/hooks',
headers: {
'X-TOKEN': token
'Authorization': `Bearer ${token}`
},
json: true,
body: {
Expand All @@ -38,7 +38,7 @@ module.exports = {
method: 'DELETE',
url: `https://calendly.com/api/v1/hooks/${webhookId}`,
headers: {
'X-TOKEN': token
'Authorization': `Bearer ${token}`
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = {

return this.unregisterWebhook(context)
.then(() => {
return commons.registerWebhookSubscription(context.auth.apiKey, 'invitee.canceled', url);
return commons.registerWebhookSubscription(context.auth.accessToken, 'invitee.canceled', url);
}).then(response => {
return context.saveState({ webhookId: response.id });
});
Expand All @@ -64,6 +64,6 @@ module.exports = {
return Promise.resolve();
}

return commons.removeWebhookSubscription(webhookId, context.auth.apiKey);
return commons.removeWebhookSubscription(webhookId, context.auth.accessToken);
}
};
4 changes: 2 additions & 2 deletions src/appmixer/calendly/events/InviteeCreated/InviteeCreated.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = {

return this.unregisterWebhook(context)
.then(() => {
return commons.registerWebhookSubscription(context.auth.apiKey, 'invitee.created', url);
return commons.registerWebhookSubscription(context.auth.accessToken, 'invitee.created', url);
}).then(response => {
return context.saveState({ webhookId: response.id });
});
Expand All @@ -66,6 +66,6 @@ module.exports = {
return Promise.resolve();
}

return commons.removeWebhookSubscription(webhookId, context.auth.apiKey);
return commons.removeWebhookSubscription(webhookId, context.auth.accessToken);
}
};

0 comments on commit b3e65fc

Please sign in to comment.