mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
OauthFlowSetup
This commit is contained in:
parent
d74062b724
commit
ad414fb445
6 changed files with 321 additions and 14 deletions
|
|
@ -193,7 +193,8 @@ class DataSourceManagerComponent extends React.Component {
|
|||
createDataSource = () => {
|
||||
const { appId, options, selectedDataSource, selectedDataSourcePluginId, dataSourceMeta, dataSourceSchema } =
|
||||
this.state;
|
||||
const OAuthDs = ['slack', 'zendesk', 'googlesheets'];
|
||||
console.log('selectedDataSource from DatasourceManager', selectedDataSource);
|
||||
const OAuthDs = ['slack', 'zendesk', 'googlesheets', 'salesforce'];
|
||||
const name = selectedDataSource.name;
|
||||
const kind = selectedDataSource.kind;
|
||||
const pluginId = selectedDataSourcePluginId;
|
||||
|
|
|
|||
|
|
@ -155,6 +155,8 @@ const DynamicForm = ({
|
|||
return OpenApi;
|
||||
case 'react-component-zendesk':
|
||||
return Zendesk;
|
||||
case 'react-component-salesforce':
|
||||
return Salesforce;
|
||||
default:
|
||||
return <div>Type is invalid</div>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ const Salesforce = ({ optionchanged, createDataSource, options, isSaving, select
|
|||
{ value: 'v2', label: 'v2' },
|
||||
];
|
||||
function authSalesforce() {
|
||||
const provider = selectedDataSource?.kind;
|
||||
const provider = 'salesforce';
|
||||
const plugin_id = selectedDataSource?.plugin?.id;
|
||||
const source_options = options;
|
||||
setAuthStatus('waiting_for_url');
|
||||
|
|
@ -24,26 +24,39 @@ const Salesforce = ({ optionchanged, createDataSource, options, isSaving, select
|
|||
.fetchOauth2BaseUrl(provider, plugin_id, source_options)
|
||||
.then((data) => {
|
||||
console.log('options', source_options);
|
||||
console.log('data from Oauth', data);
|
||||
console.log('data from Oauth', data.url);
|
||||
console.log('selectedDataSource.kind', selectedDataSource.kind);
|
||||
localStorage.setItem('sourceWaitingForOAuth', 'newSource');
|
||||
optionchanged('provider', provider).then(() => {
|
||||
optionchanged('oauth2', true);
|
||||
optionchanged('plugin_id', plugin_id);
|
||||
});
|
||||
setAuthStatus('waiting_for_token');
|
||||
window.open(data.url);
|
||||
})
|
||||
.catch(({ error }) => {
|
||||
toast.error(error);
|
||||
setAuthStatus(null);
|
||||
});
|
||||
}
|
||||
function saveDataSource() {
|
||||
console.log('selectedDS', selectedDataSource);
|
||||
optionchanged('code', localStorage.getItem('OAuthCode')).then(() => {
|
||||
createDataSource();
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
<label className="form-label mt-3">API Version</label>
|
||||
<label className="form-label text-muted mt-3">API version</label>
|
||||
<Select
|
||||
width="100%"
|
||||
type="select"
|
||||
className="form-control"
|
||||
options={selectOptions}
|
||||
onChange={(e) => optionchanged('api_version', e.target.value)}
|
||||
value={options?.api_version?.value ?? ''}
|
||||
></Select>
|
||||
value={options?.api_version?.value}
|
||||
onChange={(value) => optionchanged('api_version', value)}
|
||||
width={'100%'}
|
||||
useMenuPortal={false}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="form-label mt-3">Client ID</label>
|
||||
|
|
@ -65,6 +78,7 @@ const Salesforce = ({ optionchanged, createDataSource, options, isSaving, select
|
|||
value={options?.client_secret?.value ?? ''}
|
||||
placeholder="Client Secret"
|
||||
workspaceConstants={workspaceConstants}
|
||||
encrypted={true}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
|
|
@ -79,7 +93,27 @@ const Salesforce = ({ optionchanged, createDataSource, options, isSaving, select
|
|||
</div>
|
||||
<div className="row mt-3">
|
||||
<center>
|
||||
<Button onClick={() => authSalesforce()}>{t('slack.connectSalesforce', 'Connect to Salesforce')}</Button>
|
||||
{authStatus === 'waiting_for_token' && (
|
||||
<div>
|
||||
<Button
|
||||
className={`m2 ${isSaving ? ' loading' : ''}`}
|
||||
disabled={isSaving}
|
||||
onClick={() => saveDataSource()}
|
||||
>
|
||||
{isSaving ? t('globals.saving', 'Saving...') : t('globals.saveDatasource', 'Save data source')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(!authStatus || authStatus === 'waiting_for_url') && (
|
||||
<Button
|
||||
className={`m2 ${authStatus === 'waiting_for_url' ? ' btn-loading' : ''}`}
|
||||
disabled={isSaving}
|
||||
onClick={() => authSalesforce()}
|
||||
>
|
||||
{t('slack.connectSalesforce', 'Connect to Salesforce')}
|
||||
</Button>
|
||||
)}
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
243
marketplace/package-lock.json
generated
243
marketplace/package-lock.json
generated
|
|
@ -6737,6 +6737,73 @@
|
|||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@supabase/auth-js": {
|
||||
"version": "2.63.0",
|
||||
"resolved": "https://registry.npmjs.org/@supabase/auth-js/-/auth-js-2.63.0.tgz",
|
||||
"integrity": "sha512-yIgcHnlgv24GxHtVGUhwGqAFDyJkPIC/xjx7HostN08A8yCy8HIfl4JEkTKyBqD1v1L05jNEJOUke4Lf4O1+Qg==",
|
||||
"dependencies": {
|
||||
"@supabase/node-fetch": "^2.6.14"
|
||||
}
|
||||
},
|
||||
"node_modules/@supabase/functions-js": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@supabase/functions-js/-/functions-js-2.2.2.tgz",
|
||||
"integrity": "sha512-sJGq1nludmi7pY/fdtCpyY/pYonx7MfHdN408bqb736guWcVI1AChYVbI4kUM978EuOE4Ci6l7bUudfGg07QRw==",
|
||||
"dependencies": {
|
||||
"@supabase/node-fetch": "^2.6.14"
|
||||
}
|
||||
},
|
||||
"node_modules/@supabase/node-fetch": {
|
||||
"version": "2.6.15",
|
||||
"resolved": "https://registry.npmjs.org/@supabase/node-fetch/-/node-fetch-2.6.15.tgz",
|
||||
"integrity": "sha512-1ibVeYUacxWYi9i0cf5efil6adJ9WRyZBLivgjs+AUpewx1F3xPi7gLgaASI2SmIQxPoCEjAsLAzKPgMJVgOUQ==",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@supabase/postgrest-js": {
|
||||
"version": "1.15.0",
|
||||
"resolved": "https://registry.npmjs.org/@supabase/postgrest-js/-/postgrest-js-1.15.0.tgz",
|
||||
"integrity": "sha512-U4bwBOrhsXWqDjZiYNbVqMBtRGgIIYE0kE5ZNSwsIbeBWfr/UxOMrnkIQUBGIZRhpYW/tw1WnTdRl1AGNyaxcw==",
|
||||
"dependencies": {
|
||||
"@supabase/node-fetch": "^2.6.14"
|
||||
}
|
||||
},
|
||||
"node_modules/@supabase/realtime-js": {
|
||||
"version": "2.9.3",
|
||||
"resolved": "https://registry.npmjs.org/@supabase/realtime-js/-/realtime-js-2.9.3.tgz",
|
||||
"integrity": "sha512-lAp50s2n3FhGJFq+wTSXLNIDPw5Y0Wxrgt44eM5nLSA3jZNUUP3Oq2Ccd1CbZdVntPCWLZvJaU//pAd2NE+QnQ==",
|
||||
"dependencies": {
|
||||
"@supabase/node-fetch": "^2.6.14",
|
||||
"@types/phoenix": "^1.5.4",
|
||||
"@types/ws": "^8.5.10",
|
||||
"ws": "^8.14.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@supabase/storage-js": {
|
||||
"version": "2.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@supabase/storage-js/-/storage-js-2.5.5.tgz",
|
||||
"integrity": "sha512-OpLoDRjFwClwc2cjTJZG8XviTiQH4Ik8sCiMK5v7et0MDu2QlXjCAW3ljxJB5+z/KazdMOTnySi+hysxWUPu3w==",
|
||||
"dependencies": {
|
||||
"@supabase/node-fetch": "^2.6.14"
|
||||
}
|
||||
},
|
||||
"node_modules/@supabase/supabase-js": {
|
||||
"version": "2.42.0",
|
||||
"resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.42.0.tgz",
|
||||
"integrity": "sha512-1PDqJiA4iG45w3AAu6xkccJ3wPqlGJUoz9CPhScRLLTStxhewYhz0mjryTpXz1kgtNHdUAsirALreezn8UZMjA==",
|
||||
"dependencies": {
|
||||
"@supabase/auth-js": "2.63.0",
|
||||
"@supabase/functions-js": "2.2.2",
|
||||
"@supabase/node-fetch": "2.6.15",
|
||||
"@supabase/postgrest-js": "1.15.0",
|
||||
"@supabase/realtime-js": "2.9.3",
|
||||
"@supabase/storage-js": "2.5.5"
|
||||
}
|
||||
},
|
||||
"node_modules/@tooljet-marketplace/awsredshift": {
|
||||
"resolved": "plugins/awsredshift",
|
||||
"link": true
|
||||
|
|
@ -6765,6 +6832,10 @@
|
|||
"resolved": "plugins/plivo",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@tooljet-marketplace/pocketbase": {
|
||||
"resolved": "plugins/pocketbase",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@tooljet-marketplace/s3": {
|
||||
"resolved": "plugins/s3",
|
||||
"link": true
|
||||
|
|
@ -6773,6 +6844,10 @@
|
|||
"resolved": "plugins/salesforce",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@tooljet-marketplace/supabase": {
|
||||
"resolved": "plugins/supabase",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@tooljet-marketplace/textract": {
|
||||
"resolved": "plugins/textract",
|
||||
"link": true
|
||||
|
|
@ -6954,6 +7029,11 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/phoenix": {
|
||||
"version": "1.6.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/phoenix/-/phoenix-1.6.4.tgz",
|
||||
"integrity": "sha512-B34A7uot1Cv0XtaHRYDATltAdKx0BvVKNgYNqE4WjtPUa4VQJM7kxeXcVKaH+KS+kCmZ+6w+QaUdcljiheiBJA=="
|
||||
},
|
||||
"node_modules/@types/prettier": {
|
||||
"version": "2.7.2",
|
||||
"dev": true,
|
||||
|
|
@ -6970,6 +7050,14 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/ws": {
|
||||
"version": "8.5.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.10.tgz",
|
||||
"integrity": "sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/yargs": {
|
||||
"version": "17.0.24",
|
||||
"dev": true,
|
||||
|
|
@ -14708,6 +14796,11 @@
|
|||
"xmlbuilder": "^9.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/pocketbase": {
|
||||
"version": "0.21.1",
|
||||
"resolved": "https://registry.npmjs.org/pocketbase/-/pocketbase-0.21.1.tgz",
|
||||
"integrity": "sha512-0PvCP4pKtxsV9kwldEGyibEvhwOcx9jSCrz3WN5CgPILJfM0z76f1op9WE8/8UgikDsMdRsc5iBLfKintrJS1g=="
|
||||
},
|
||||
"node_modules/postcss-selector-parser": {
|
||||
"version": "6.0.11",
|
||||
"dev": true,
|
||||
|
|
@ -16849,6 +16942,26 @@
|
|||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.16.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz",
|
||||
"integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/xml2js": {
|
||||
"version": "0.4.19",
|
||||
"license": "MIT",
|
||||
|
|
@ -16958,6 +17071,7 @@
|
|||
}
|
||||
},
|
||||
"plugins/engagespot": {
|
||||
"name": "@tooljet-marketplace/engagespot",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@engagespot/node": "^1.5.1",
|
||||
|
|
@ -17016,6 +17130,17 @@
|
|||
"typescript": "^4.7.4"
|
||||
}
|
||||
},
|
||||
"plugins/pocketbase": {
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@tooljet-marketplace/common": "^1.0.0",
|
||||
"pocketbase": "^0.21.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "^0.34.0",
|
||||
"typescript": "^4.7.4"
|
||||
}
|
||||
},
|
||||
"plugins/s3": {
|
||||
"name": "@tooljet-marketplace/s3",
|
||||
"version": "1.0.0",
|
||||
|
|
@ -17030,6 +17155,7 @@
|
|||
}
|
||||
},
|
||||
"plugins/salesforce": {
|
||||
"name": "@tooljet-marketplace/salesforce",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@tooljet-marketplace/common": "^1.0.0",
|
||||
|
|
@ -17040,6 +17166,17 @@
|
|||
"typescript": "^4.7.4"
|
||||
}
|
||||
},
|
||||
"plugins/supabase": {
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@supabase/supabase-js": "^2.41.1",
|
||||
"@tooljet-marketplace/common": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "^0.34.0",
|
||||
"typescript": "^4.7.4"
|
||||
}
|
||||
},
|
||||
"plugins/textract": {
|
||||
"name": "@tooljet-marketplace/textract",
|
||||
"version": "1.0.0",
|
||||
|
|
@ -21935,6 +22072,70 @@
|
|||
"tslib": "^2.5.0"
|
||||
}
|
||||
},
|
||||
"@supabase/auth-js": {
|
||||
"version": "2.63.0",
|
||||
"resolved": "https://registry.npmjs.org/@supabase/auth-js/-/auth-js-2.63.0.tgz",
|
||||
"integrity": "sha512-yIgcHnlgv24GxHtVGUhwGqAFDyJkPIC/xjx7HostN08A8yCy8HIfl4JEkTKyBqD1v1L05jNEJOUke4Lf4O1+Qg==",
|
||||
"requires": {
|
||||
"@supabase/node-fetch": "^2.6.14"
|
||||
}
|
||||
},
|
||||
"@supabase/functions-js": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@supabase/functions-js/-/functions-js-2.2.2.tgz",
|
||||
"integrity": "sha512-sJGq1nludmi7pY/fdtCpyY/pYonx7MfHdN408bqb736guWcVI1AChYVbI4kUM978EuOE4Ci6l7bUudfGg07QRw==",
|
||||
"requires": {
|
||||
"@supabase/node-fetch": "^2.6.14"
|
||||
}
|
||||
},
|
||||
"@supabase/node-fetch": {
|
||||
"version": "2.6.15",
|
||||
"resolved": "https://registry.npmjs.org/@supabase/node-fetch/-/node-fetch-2.6.15.tgz",
|
||||
"integrity": "sha512-1ibVeYUacxWYi9i0cf5efil6adJ9WRyZBLivgjs+AUpewx1F3xPi7gLgaASI2SmIQxPoCEjAsLAzKPgMJVgOUQ==",
|
||||
"requires": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"@supabase/postgrest-js": {
|
||||
"version": "1.15.0",
|
||||
"resolved": "https://registry.npmjs.org/@supabase/postgrest-js/-/postgrest-js-1.15.0.tgz",
|
||||
"integrity": "sha512-U4bwBOrhsXWqDjZiYNbVqMBtRGgIIYE0kE5ZNSwsIbeBWfr/UxOMrnkIQUBGIZRhpYW/tw1WnTdRl1AGNyaxcw==",
|
||||
"requires": {
|
||||
"@supabase/node-fetch": "^2.6.14"
|
||||
}
|
||||
},
|
||||
"@supabase/realtime-js": {
|
||||
"version": "2.9.3",
|
||||
"resolved": "https://registry.npmjs.org/@supabase/realtime-js/-/realtime-js-2.9.3.tgz",
|
||||
"integrity": "sha512-lAp50s2n3FhGJFq+wTSXLNIDPw5Y0Wxrgt44eM5nLSA3jZNUUP3Oq2Ccd1CbZdVntPCWLZvJaU//pAd2NE+QnQ==",
|
||||
"requires": {
|
||||
"@supabase/node-fetch": "^2.6.14",
|
||||
"@types/phoenix": "^1.5.4",
|
||||
"@types/ws": "^8.5.10",
|
||||
"ws": "^8.14.2"
|
||||
}
|
||||
},
|
||||
"@supabase/storage-js": {
|
||||
"version": "2.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@supabase/storage-js/-/storage-js-2.5.5.tgz",
|
||||
"integrity": "sha512-OpLoDRjFwClwc2cjTJZG8XviTiQH4Ik8sCiMK5v7et0MDu2QlXjCAW3ljxJB5+z/KazdMOTnySi+hysxWUPu3w==",
|
||||
"requires": {
|
||||
"@supabase/node-fetch": "^2.6.14"
|
||||
}
|
||||
},
|
||||
"@supabase/supabase-js": {
|
||||
"version": "2.42.0",
|
||||
"resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.42.0.tgz",
|
||||
"integrity": "sha512-1PDqJiA4iG45w3AAu6xkccJ3wPqlGJUoz9CPhScRLLTStxhewYhz0mjryTpXz1kgtNHdUAsirALreezn8UZMjA==",
|
||||
"requires": {
|
||||
"@supabase/auth-js": "2.63.0",
|
||||
"@supabase/functions-js": "2.2.2",
|
||||
"@supabase/node-fetch": "2.6.15",
|
||||
"@supabase/postgrest-js": "1.15.0",
|
||||
"@supabase/realtime-js": "2.9.3",
|
||||
"@supabase/storage-js": "2.5.5"
|
||||
}
|
||||
},
|
||||
"@tooljet-marketplace/awsredshift": {
|
||||
"version": "file:plugins/awsredshift",
|
||||
"requires": {
|
||||
|
|
@ -21994,6 +22195,15 @@
|
|||
"typescript": "^4.7.4"
|
||||
}
|
||||
},
|
||||
"@tooljet-marketplace/pocketbase": {
|
||||
"version": "file:plugins/pocketbase",
|
||||
"requires": {
|
||||
"@tooljet-marketplace/common": "^1.0.0",
|
||||
"@vercel/ncc": "^0.34.0",
|
||||
"pocketbase": "^0.21.1",
|
||||
"typescript": "^4.7.4"
|
||||
}
|
||||
},
|
||||
"@tooljet-marketplace/s3": {
|
||||
"version": "file:plugins/s3",
|
||||
"requires": {
|
||||
|
|
@ -22013,6 +22223,15 @@
|
|||
"typescript": "^4.7.4"
|
||||
}
|
||||
},
|
||||
"@tooljet-marketplace/supabase": {
|
||||
"version": "file:plugins/supabase",
|
||||
"requires": {
|
||||
"@supabase/supabase-js": "^2.41.1",
|
||||
"@tooljet-marketplace/common": "^1.0.0",
|
||||
"@vercel/ncc": "^0.34.0",
|
||||
"typescript": "^4.7.4"
|
||||
}
|
||||
},
|
||||
"@tooljet-marketplace/textract": {
|
||||
"version": "file:plugins/textract",
|
||||
"requires": {
|
||||
|
|
@ -22174,6 +22393,11 @@
|
|||
"version": "4.0.0",
|
||||
"dev": true
|
||||
},
|
||||
"@types/phoenix": {
|
||||
"version": "1.6.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/phoenix/-/phoenix-1.6.4.tgz",
|
||||
"integrity": "sha512-B34A7uot1Cv0XtaHRYDATltAdKx0BvVKNgYNqE4WjtPUa4VQJM7kxeXcVKaH+KS+kCmZ+6w+QaUdcljiheiBJA=="
|
||||
},
|
||||
"@types/prettier": {
|
||||
"version": "2.7.2",
|
||||
"dev": true,
|
||||
|
|
@ -22187,6 +22411,14 @@
|
|||
"version": "2.0.1",
|
||||
"dev": true
|
||||
},
|
||||
"@types/ws": {
|
||||
"version": "8.5.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.10.tgz",
|
||||
"integrity": "sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==",
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/yargs": {
|
||||
"version": "17.0.24",
|
||||
"dev": true,
|
||||
|
|
@ -27222,6 +27454,11 @@
|
|||
"xmlbuilder": "^9.0.1"
|
||||
}
|
||||
},
|
||||
"pocketbase": {
|
||||
"version": "0.21.1",
|
||||
"resolved": "https://registry.npmjs.org/pocketbase/-/pocketbase-0.21.1.tgz",
|
||||
"integrity": "sha512-0PvCP4pKtxsV9kwldEGyibEvhwOcx9jSCrz3WN5CgPILJfM0z76f1op9WE8/8UgikDsMdRsc5iBLfKintrJS1g=="
|
||||
},
|
||||
"postcss-selector-parser": {
|
||||
"version": "6.0.11",
|
||||
"dev": true,
|
||||
|
|
@ -28586,6 +28823,12 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"ws": {
|
||||
"version": "8.16.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz",
|
||||
"integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==",
|
||||
"requires": {}
|
||||
},
|
||||
"xml2js": {
|
||||
"version": "0.4.19",
|
||||
"requires": {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,32 @@ export default class Salesforce implements QueryService {
|
|||
const fullUrl = `${host}${subpath ? subpath : '/'}`;
|
||||
const redirectUri = `${fullUrl}oauth2/authorize`;
|
||||
const client_secret = source_options.client_secret.value;
|
||||
return `https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=${client_id}&redirect_uri=${redirectUri}&state=YOUR_STATE`;
|
||||
const oauth2 = new jsforce.OAuth2({
|
||||
clientId: client_id,
|
||||
clientSecret: client_secret,
|
||||
redirectUri: redirectUri,
|
||||
});
|
||||
const authorizationUrl = oauth2.getAuthorizationUrl({
|
||||
scope: 'full',
|
||||
});
|
||||
return authorizationUrl;
|
||||
}
|
||||
async accessDetailsFrom(authCode: string, source_options): Promise<object> {
|
||||
const client_id = source_options.client_id.value;
|
||||
const host = process.env.TOOLJET_HOST;
|
||||
const subpath = process.env.SUB_PATH;
|
||||
const fullUrl = `${host}${subpath ? subpath : '/'}`;
|
||||
const redirectUri = `${fullUrl}oauth2/authorize`;
|
||||
const client_secret = source_options.client_secret.value;
|
||||
const oauth2 = new jsforce.OAuth2({
|
||||
clientId: client_id,
|
||||
clientSecret: client_secret,
|
||||
redirectUri: redirectUri,
|
||||
});
|
||||
const conn = new jsforce.Connection({ oauth2: oauth2 });
|
||||
const response = await conn.authorize(authCode);
|
||||
const authDetails = [];
|
||||
authDetails.push(['response', response]);
|
||||
return authDetails;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import allPlugins from '@tooljet/plugins/dist/server';
|
||||
import { Injectable, NotAcceptableException, NotImplementedException } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { EntityManager, getManager, Repository } from 'typeorm';
|
||||
|
|
@ -364,8 +363,10 @@ export class DataSourcesService {
|
|||
if (findOption(options, 'oauth2') && findOption(options, 'code')) {
|
||||
const provider = findOption(options, 'provider')['value'];
|
||||
const authCode = findOption(options, 'code')['value'];
|
||||
const plugin_id = findOption(options, 'plugin_id')['value'];
|
||||
const queryService = await this.pluginsHelper.getService(plugin_id, provider);
|
||||
|
||||
const queryService = new allPlugins[provider]();
|
||||
//const queryService = new allPlugins[provider]();
|
||||
const accessDetails = await queryService.accessDetailsFrom(authCode, options);
|
||||
|
||||
for (const row of accessDetails) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue