Add sandbox option to Salesforce OAuth2 credentials (#1979)

*  Add environment dropdown to OAuth2 creds

*  Add sandbox URL to OAuth2 call

*  Revert options change

*  Set OAuth2 URLs with expressions

*  Extract instance URL from credentials
This commit is contained in:
Iván Ovejero
2021-07-14 18:51:51 +02:00
committed by GitHub
parent e40f0e00a8
commit c5a1bc007f
2 changed files with 21 additions and 6 deletions

View File

@@ -40,9 +40,8 @@ export async function salesforceApiRequest(this: IExecuteFunctions | IExecuteSin
} else {
// https://help.salesforce.com/articleView?id=remoteaccess_oauth_web_server_flow.htm&type=5
const credentialsType = 'salesforceOAuth2Api';
const credentials = this.getCredentials(credentialsType);
const subdomain = ((credentials!.accessTokenUrl as string).match(/https:\/\/(.+).salesforce\.com/) || [])[1];
const options = getOptions.call(this, method, (uri || endpoint), body, qs, `https://${subdomain}.salesforce.com`);
const credentials = this.getCredentials(credentialsType) as { oauthTokenData: { instance_url: string } };
const options = getOptions.call(this, method, (uri || endpoint), body, qs, credentials.oauthTokenData.instance_url);
Logger.debug(`Authentication for "Salesforce" node is using "OAuth2". Invoking URI ${options.uri}`);
//@ts-ignore
return await this.helpers.requestOAuth2.call(this, credentialsType, options);