Following scenario:

We need to set up a connection to an external API. This API uses the resource parameter for authentication, so using a legacy named credential is not possible.

However, the new named credential or more specifically the external credential have no option to set an authorization URL.

We have two URLs in this case:

  1. the API base URL -> https://api-url-base.com/
  2. the authorization endpoint URL -> https://api-url-base.com/account/Authenticate

The named credential needs to run it's authorization against 2) but all callouts need to go to 1) + endpoint.

Is there any way to achieve this with the new named credential system?

With Legacy Named Credentials I got the Auth Provider which has Authorize Endpoint URL and Token Endpoint URL. But no way to define the resource parameter on authentication.

1 Answer 1


Guess I'll be answering my own question :)

The "trick" is that you need to get the token on your own and use merge fields in the request. (Make sure to activate them for the named credential)

req.setEndpoint('callout:ApiBase/' + 'account/Authenticate');
req.setHeader('Content-Type', 'application/x-www-form-urlencoded');



And then perform any further callouts with the retrieved token. This is not exactly what I'd call an optimal solution, since it still takes away the automated authentication we had in legacy named credentials, but it also allows us to store our credential data safely without the use of custom metadata.

  • it still takes away the automated authentication we had in legacy named credentials - no, it doesn't. With respect to client_credentials grant type, the functionality of NC hasn't changed from legacy to new, External Creds-linked flavor.
    – identigral
    Mar 14, 2023 at 15:59

You must log in to answer this question.

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