0

I'm at a point in my development that I now get a string in JSON format from a third party with the access token and refresh token

{access_token=abcdefhijklmno, expires_in=86400, refresh_token=abcdefhijklmno123, scope=full|*****.infusionsoft.com, token_type=bearer}

What is the best way to store this data for later use?

1 Answer 1

2

Your best option is to use a named credential. When you establish a named credential for an OAuth provider, you declare if it's per user or one "named principal" for the org. Then, you authenticate as an admin, and optionally your users can each authenticate to their identity.

Then you can make callouts that look like this:

HttpRequest req = new HttpRequest();
req.setEndpoint('callout:My_Named_Credential/some_path');

and the framework will automatically handle the OAuth flow for you, and keep your access token and refresh token in encrypted storage that cannot be accessed, even in circumstances that encrypted fields can be.

1
  • Are you aware if named credentials can be updated in the apex class they are called from?
    – Tyler Zika
    Sep 19, 2016 at 20:29

You must log in to answer this question.

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