1

I'm in the process of integrating Salesforce with an external service. In our scenario, an LWC page calls a method in its Apex controller. This method then initiates an external callout to obtain a JSON object.

The integration procedure is as follows:

The client needs to call the authorization endpoint, providing the client ID, client secret, and scope to obtain an access token.

Once the token is obtained, a POST request is sent to the external service. This request includes the token, specific header parameters, and the necessary payload to fetch the JSON response.

I've been successful in executing these requests using Postman.

  • How can I leverage Named Credentials and External Credentials for a secure implementation?
  • Given that the access token expires every few hours, can Named Credentials manage its renewal based on the described scenario?

I prefer to avoid legacy Named Credentials. Unfortunately, I haven't been able to find comprehensive information on the new version of Named Credentials specific to this scenario.

3
  • 1
    Welcome to SFSE! Please take a moment to read How to Ask and take the tour. Have you done any research into what NC supports versus what you need? There's official documentation and Q&As here. If you have tried implementing, including a Minimal, Complete and Reproducible Example would be helpful. The scope of oAuth flows supported out of the box is the same for both legacy and new (External) NCs.
    – identigral
    Commented Aug 6, 2023 at 18:08
  • Hi @identigral, thank you for your reply. I couldn't find any answer despite reading so many posts. In our scenario: SF makes a call to the token end point with client id, client secret and scope to get access token. (Oauth 2) Than makes a POST request to an endpoint with access token header alongside other headers and payload. In External Credentials, there are two OAuth 2.0 flow types: Browser Flow and JWT Bearer Flow. None of them seem to be suitable for us. Can Named Credential/External Credential handle authentication in this scenario, or auth should be done manually in Apex?
    – Akif
    Commented Aug 8, 2023 at 19:00
  • It's unclear what oAuth flow your app supports but it sounds like you've answered your own question.
    – identigral
    Commented Aug 11, 2023 at 17:47

0

You must log in to answer this question.

Browse other questions tagged .