I am again trying to understand what is the best possible option to securely making the apex callouts from a trigger to external application which supports OAuth2. I am not building any application/package here. I am very new to Salesforce and the integration with external system, so pardon me if I am asking a very lame question. I am kind of stuck not able to understand what is the right choice for my scenario. The end point supports the grant type
As a POC I was able to harcode all the credentials in Apex and I was able to call external system with out any issues. As this not secure I tried exploring the options mentioned https://developer.salesforce.com/page/Secure_Coding_Storing_Secrets
- I tried to use the named credentials but found that grant_type
client_credentialsis not supported as asked in the question here
- I tried to create the Custom metadata type and stored the credentials like below but looks like I cannot store the credentials like above as they are not very secure.
- Read that I could also use a Custom object with the encrypted field also having the FLS to store these credentials and use it APEX
- Custom settings - I am not sure if I can use the Custom settings as when I tried to create a it I see the warning message where salesforce recommending to use the Custom metadata type
We dont have the platform encryption turned on in our ORg, should we enable that to created the encrypted fields on the Cutom metadta dattype/object/ settings encrypt it and when we reterive in apex should we be decrypting them? Please suggest me what is the best option to use here and also store the access token retrieved so I can use it until it expired.