Skip to content

Commit

Permalink
Calendly oauth updated from ApiKey to Oauth2
Browse files Browse the repository at this point in the history
  • Loading branch information
sayam-nasir committed Oct 4, 2024
1 parent 3ec64e3 commit dd3bdb1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 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
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}`,

Check failure on line 19 in src/appmixer/calendly/calendly-commons.js

View workflow job for this annotation

GitHub Actions / build

Unexpected trailing comma
},
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}`,

Check failure on line 41 in src/appmixer/calendly/calendly-commons.js

View workflow job for this annotation

GitHub Actions / build

Unexpected trailing comma
}
});
}
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 dd3bdb1

Please sign in to comment.