Integration to Salesforce through REST API without using consumer secret/key

accesstokenapioauth2rest-api

I am trying to connect with the Salesforce via API call. I got the access token first by providing username, password, consumer key, consumer secret, grant_type. Then I used the access token and made the second call which is the actual API call for salesforce.

My question is, Is it possible to connect the Salesforce just using access token,username and password without really providing the consumer key and consumer secret or we definitely need the consumer key and consumer secret to connect with Salesforce.

We are using REST API and I don't want to use consumer key and consumer secret. Please suggested how to achieve this.

Best Answer

If you have the access token or a session id (but preferably the access token), then you don't need anything else. It's getting the access token that requires the connected app and the user details.

There are a selection of OAuth 2.0 flows. The flow you're currently using is the username-password flow, which is only recommended for testing.

The consumer key (client id) is always required. The consumer secret (client secret) is not required in all flows.

Most of the OAuth flows are interactive, meaning that they require the user to interact with it to supply their username and password themselves (via a small, separate window that anyone who has used the Salesforce-provided DataLoader or the (third-party) Salesforce Workbench will be familiar with).

If you're working in a scenario where user interaction is not possible (e.g. you have a server that is running a shell script on a schedule via cron), then you'd need to use a non-interactive flow such as the JWT Bearer flow.