3

An External App, lets call it App A makes a REST API call to Salesforce for Candidate Account. (Account: RecordTYpe = Candidate)

I have -

  • Create a Connected App 'External App A', Created an Apex Class 'Candidate Accounts' and exposed it as a web service.
  • Created an API Only user in salesforce (License Type: Salesforce, Custom Profile: API Only)
  • Gave the Consumer Key, Secret Key, Username and Password to the External App A to be able to get authorized in Salesforce and get the data.

So far so good. Everything is functioning perfectly.

Now, another External App, lets call it App B would like to make a REST API call to Salesforce for Recruiter Account. (Account: RecordTYpe = Recruiter)

  • I have created an Apex Class 'Recruiter Accounts' and exposed it as a webservice.

My question is -

Can i repurpose 'External App A ', and the API Only user for Authorzing External App B?

i.e Can i give the same Consumer Key, Secret Key, Username and Password to the External App B to be authorized in Salesforce and get the Recruiter Account data.?

Or Do i have to create another Connected App, and another user in salesforce for External App B ?

Thanks !!

2 Answers 2

5

Yes, you can re-purpose it.

Best practice is that each client (App A vs App B) has its own connected app. With 2 connected apps (1 per client), you can still use the same user account to authorize access to the app...but each client will have its own set of credentials (consumer key + secret). Why 2 apps vs 1? Consider a scenario where at some point in the future you may want to change something about the way app A connects without impacting app B.

1
  • 2
    Also, there is a five session limit per user per connected app, so using more apps means you won't one day accidentally run into session issues.
    – sfdcfox
    Commented Mar 22, 2020 at 21:21
4

An API user can be used across multiple sessions, and Connected Apps can be used for multiple purposes, but you'll need to keep in mind that there are a few limits.

Connected Apps can only have five sessions per user, so using separate Connected Apps will reduce the possibility of sessions expiring early. This can cause erratic app behavior.

Users can only have fifty open database cursors open at once. Make sure you're not multi-threading in your apps excessively, and avoid using the same user for too many different apps/purposes. This can cause queries to fail.

As a bonus, using separate Connected Apps will allow you to identify API usage per app, as well as being able to determine which session to terminate if you need to block access for some reason.

So, while you could repurpose the same Connected App, you should probably avoid doing so. There's no limit to how many apps you can create, so there's no real benefit to reusing the app.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .