Skip to content

Commit

Permalink
Merge branch 'getOauthInfoAsync'
Browse files Browse the repository at this point in the history
  • Loading branch information
DaKingKong committed Aug 28, 2024
2 parents 87304a9 + da1d357 commit 9ba58fd
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/adapters/bullhorn/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function getAuthType() {
return 'oauth';
}

function getOauthInfo({ tokenUrl }) {
async function getOauthInfo({ tokenUrl }) {
return {
clientId: process.env.BULLHORN_CLIENT_ID,
clientSecret: process.env.BULLHORN_CLIENT_SECRET,
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/clio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function getAuthType() {
return 'oauth';
}

function getOauthInfo() {
async function getOauthInfo() {
return {
clientId: process.env.CLIO_CLIENT_ID,
clientSecret: process.env.CLIO_CLIENT_SECRET,
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "RingCentral Labs",
"websiteUrl": "https://github.com/ringcentral/rc-unified-crm-extension",
"iconUrl": "https://lh3.googleusercontent.com/opCzi-yJ2FLuN_XmmZPj_OuKtXhgW6w77_8tZPH5Y6tFw2Zwk8T-XGW0z0Xio_FgdvTRLJ3k-kYplXtmUhKjzxMkJEQ=s60",
"supportUrl": "https://forms.gle/2uC1FSiRq4QapPpD6"
"supportUrl": "https://community.ringcentral.com/groups/unified-crm-extension-22?utm_source=crm-extension&utm_medium=link&utm_campaign=in-app-link"
},
"platforms": {
"pipedrive": {
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/netsuite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function getAuthType() {
}


function getOauthInfo({ hostname }) {
async function getOauthInfo({ hostname }) {
const tokenUrl = `https://${hostname.split(".")[0]}.suitetalk.api.netsuite.com/services/rest/auth/oauth2/v1/token`;
return {
clientId: process.env.NETSUITE_CRM_CLIENT_ID,
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/pipedrive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function getAuthType() {
return 'oauth';
}

function getOauthInfo() {
async function getOauthInfo() {
return {
clientId: process.env.PIPEDRIVE_CLIENT_ID,
clientSecret: process.env.PIPEDRIVE_CLIENT_SECRET,
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/testCRM/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function getBasicAuth({ apiKey }) {
exports.getBasicAuth = getBasicAuth;

// CHOOSE: If using OAuth
// function getOauthInfo() {
// async function getOauthInfo() {
// return {
// clientId: process.env.TEST_CRM_CLIENT_ID,
// clientSecret: process.env.TEST_CRM_CLIENT_SECRET,
Expand Down
2 changes: 1 addition & 1 deletion src/core/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Op = require('sequelize').Op;

async function onOAuthCallback({ platform, hostname, tokenUrl, callbackUri, apiUrl, username, query }) {
const platformModule = require(`../adapters/${platform}`);
const oauthInfo = platformModule.getOauthInfo({ tokenUrl, hostname });
const oauthInfo = await platformModule.getOauthInfo({ tokenUrl, hostname, rcAccountId: query.rcAccountId });

// Some platforms require different oauth queries, this won't affect normal OAuth process unless CRM module implements getOverridingOAuthOption() method
let overridingOAuthOption = null;
Expand Down
4 changes: 2 additions & 2 deletions src/core/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function findContact({ platform, userId, phoneNumber, overridingFormat })
let authHeader = '';
switch (authType) {
case 'oauth':
const oauthApp = oauth.getOAuthApp(platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname }));
const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
authHeader = `Bearer ${user.accessToken}`;
break;
Expand Down Expand Up @@ -65,7 +65,7 @@ async function createContact({ platform, userId, phoneNumber, newContactName, ne
let authHeader = '';
switch (authType) {
case 'oauth':
const oauthApp = oauth.getOAuthApp(platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname }));
const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
authHeader = `Bearer ${user.accessToken}`;
break;
Expand Down
8 changes: 4 additions & 4 deletions src/core/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function createCallLog({ platform, userId, incomingData }) {
let authHeader = '';
switch (authType) {
case 'oauth':
const oauthApp = oauth.getOAuthApp(platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname }));
const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
authHeader = `Bearer ${user.accessToken}`;
break;
Expand Down Expand Up @@ -107,7 +107,7 @@ async function getCallLog({ userId, sessionIds, platform, requireDetails }) {
let authHeader = '';
switch (authType) {
case 'oauth':
const oauthApp = oauth.getOAuthApp(platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname }));
const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
authHeader = `Bearer ${user.accessToken}`;
break;
Expand Down Expand Up @@ -170,7 +170,7 @@ async function updateCallLog({ platform, userId, incomingData }) {
let authHeader = '';
switch (authType) {
case 'oauth':
const oauthApp = oauth.getOAuthApp(platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname }));
const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
authHeader = `Bearer ${user.accessToken}`;
break;
Expand Down Expand Up @@ -230,7 +230,7 @@ async function createMessageLog({ platform, userId, incomingData }) {
let authHeader = '';
switch (authType) {
case 'oauth':
const oauthApp = oauth.getOAuthApp(platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname }));
const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
authHeader = `Bearer ${user.accessToken}`;
break;
Expand Down

0 comments on commit 9ba58fd

Please sign in to comment.