While integrating facebook / Twitter / Other social websites with salesforce, what are the proper method to set the client ID and Client Secret ?

I had stored in salesforce. While retrieving it back within static method It shows Error of de reference null - Because of static context is totally different than regular context.

What should be the proper method to save and retrieve client ID and client secret ?

  • In salesforce where have you saved the client ID and Client Secret ? – MIX DML Nov 28 '16 at 11:43
  • custom setting would be best. You can create private CS as well. – Tushar Sharma Nov 28 '16 at 11:43
  • In Database i am saving it. – Innodel Salesforce Nov 28 '16 at 11:44

The old answer used to be in a custom setting. That is simple, but the secrets are stored in plaintext and readable by anyone who has access to the custom setting.

If you're writing a managed package, you can go better by making it a private custom setting (in this sense, private means only readable within the package that defines the setting). Then, your code in the package can read the secrets in order to make the callout, but no-one else can read them. Obviously, you need to write a VF page (or some Apex setter method) in your package to allow users to set the secret values in the first place.

There is also the relatively new feature of Named Credentials. I haven't actually used these, but they seem to be SF's latest thinking on how to solve this problem. They bundle together the endpoint and the credentials so that your callout code is simpler. More details here: https://help.salesforce.com/articleView?id=named_credentials_about.htm&type=0&language=en_US

As for your error message: To help with that, it would be useful if you posted the relevant code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.