0

I am having to refactor a Quickbooks integration with Salesforce and am wondering the best way to store the credential information. The first developer used custom settings for most of the credentials and a field on the user object for the access token (since it is more than 255 characters). I need to move the access token elsewhere so that it is not stored in plain text but I would like to be able to easily access it from Apex code. The access token seems to be around 700 characters. Any and all advice is appreciated.

3
  • Does each user have their own access token? Only a few privileged users?
    – Adrian Larson
    Feb 13 '18 at 15:26
  • All users would have the same access token I would think. The integration needs to work regardless of the user. Im not sure the reason it is stored on the user object :) Feb 13 '18 at 15:29
  • Possible duplicate: Where to Store Token Auth?
    – Adrian Larson
    Feb 13 '18 at 15:38
2

Store it on a Named Credential. It has an OAuthToken field which you can merge into your callouts without ever needing to know its value. And in fact you won't be able to read the value after you set it.

Using the token is easy. Setting it took a little more work. You can see some more about what I did with a similar requirement here.

4
  • Is there any solution that doesnt have to use the Metadata API? Feb 13 '18 at 15:59
  • @ZackWalton That's only when setting the token. You just have to do it once in an anonymous script, then you can deploy the token to other environments without the need to use the Metadata API in every org.
    – Adrian Larson
    Feb 13 '18 at 16:01
  • The access token needs to be updated periodically and use the refresh token once expired. Maybe Im just not understanding but is this supported? Feb 13 '18 at 16:03
  • 1
    You'd just have to play around with it. I got roadblocked by politics and never took the project to completion. But it works; I was able to set up the token and authenticate. And Eric provided a complete and functioning UI that you could pull in and work with so it's less painful to set/update the token values. I recommend you try it and see what you find.
    – Adrian Larson
    Feb 13 '18 at 16:06

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.