function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bryan Leaman 6Bryan Leaman 6 

Strange behavior of OAuth2 connected app definition

I've developed some code using Salesforce REST APIs to perform simple queries from external systems. I've created a Connected App definition in my sandbox and connect to it using https://{sandbox-host-name}.my.salesforce.com with grant_type=password, our client_id, client_secret, username & password+api key and it works great.

The strange behavior is that I can use the same Consumer_Key and Consumer_Secret with our production org host with a production username, password and API key and it ALSO works great. But I haven't moved the connected app definition to production yet!

How does this meet the definition of security? Am I missing something?
Best Answer chosen by Bryan Leaman 6
SwethaSwetha (Salesforce Developers) 
HI Bryan,
Your ask looks similar to https://developer.salesforce.com/forums/?id=906F0000000AyJvIAK. According to this,

If you define a Connected App in at least in one org, that registers that Application name on the Salesforce service such that the client Id and token are now validate to perform oAuth against any other Salesforce org. This is also explained in this (https://developer.salesforce.com/blogs/developer-relations/2011/07/quick-tip-using-oauth-across-multiple-orgs.html) blog post.

"You only need to setup a single Remote Access Application and you can then use the assigned ’Client Id’ and ‘Client Secret’ values to have users log into any Salesforce Org – not just the one where the Remote Access Application was setup. This question is especially relevant to ISV partners that are developing Managed Package applications are are installed by multiple customers in their respective Orgs"

If this information helps, please mark the answer as best. Thank you

All Answers

SwethaSwetha (Salesforce Developers) 
HI Bryan,
Your ask looks similar to https://developer.salesforce.com/forums/?id=906F0000000AyJvIAK. According to this,

If you define a Connected App in at least in one org, that registers that Application name on the Salesforce service such that the client Id and token are now validate to perform oAuth against any other Salesforce org. This is also explained in this (https://developer.salesforce.com/blogs/developer-relations/2011/07/quick-tip-using-oauth-across-multiple-orgs.html) blog post.

"You only need to setup a single Remote Access Application and you can then use the assigned ’Client Id’ and ‘Client Secret’ values to have users log into any Salesforce Org – not just the one where the Remote Access Application was setup. This question is especially relevant to ISV partners that are developing Managed Package applications are are installed by multiple customers in their respective Orgs"

If this information helps, please mark the answer as best. Thank you
This was selected as the best answer
SwethaSwetha (Salesforce Developers) 
See https://salesforce.stackexchange.com/questions/213666/connected-app-built-in-sandbox-has-access-to-prod wherein user posted same ask 

https://salesforce.stackexchange.com/questions/70284/how-can-i-deploy-a-connected-app-from-my-sandbox-environment-to-my-production-en
Bryan Leaman 6Bryan Leaman 6
Thanks, Swetha.  This sounds really odd -- so in salesforce, only 1 connected app needs to be published for the world to have api access to your org, provided they have a valid userId, password & api key for your org. I've just proven that myself by connecting to my developer org using my workplace sandbox connected app (my dev org is totally independent of my employer orgs).  That really seems like almost no security at all to me.