feat(salesforce): add authentication

This commit is contained in:
Ali BARIN
2022-11-03 23:08:28 +01:00
parent 7d82ca5d3c
commit ede55a70aa
9 changed files with 289 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import { IField, IGlobalVariable } from '@automatisch/types';
import qs from 'qs';
export default async function createAuthData($: IGlobalVariable) {
try {
const oauthRedirectUrlField = $.app.auth.fields.find(
(field: IField) => field.key == 'oAuthRedirectUrl'
);
const redirectUri = oauthRedirectUrlField.value;
const searchParams = qs.stringify({
client_id: $.auth.data.consumerKey as string,
redirect_uri: redirectUri,
response_type: 'code'
})
await $.auth.set({
url: `${$.auth.data.oauth2Url}/authorize?${searchParams}`,
});
} catch (error) {
throw new Error(
`Error occured while verifying credentials: ${error}`
);
}
}