7

I have created a new Named Credential with External Credential (named B2BL_Mulesoft_Integrations) and mapped it to the correct permission sets using the Identity Type as Named Principal.

Can you please help me with what I am missing?

Update 14-Dec-2022: I have opened case# 43776623.

When I attempt to use Apex Class in Digital Experience under a Checkout Flow, it throws the exception as seen below:

15:37:59.78 (78218899)|NAMED_CREDENTIAL_RESPONSE|NamedCallout[Named Credential Id=null, Named Credential Name=null, Status Code=0, Content-Type=null, Response Size bytes=0, Overall Callout Time ms=0, Connect Time ms=0
15:37:59.10 (78972740)|EXCEPTION_THROWN|[11]|System.CalloutException: We couldn't access the credential(s). You might not have the required permissions, or the external credential "B2BL_Mulesoft_Integrations" might not exist.

It works well with System Administrator but not with the Digital Experience user assigned the permission set. I have granted access to Read+Create+Edit+Delete to the permission set User External Credentials.

Note: I have also attemted to change the code from with sharing to without sharing with no success.

The code is the usual:

HttpRequest req = new HttpRequest();
req.setEndpoint('callout:B2BL_Stock_Check');
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json');
req.setBody('...');
Http http = new Http();
HTTPResponse res = http.send(req);

External Authentication config: enter image description here

Named Credential config: enter image description here

3 Answers 3

7

As far as I can see, Named Credential mapping does not work with Permission Set Groups.

The workaround was the assign the permission set directly to the user.

I have found this Idea. I hope this was documented. It could have saved us one day. It would be even better if Permission Set Groups worked as designed.

TL;DR: as of 15-Dec-22, Named Credentials mapping works only with permission sets assigned directly to the user.

2
  • I have all in place but still seems like I am missing something, even if use my sys admin profile or I assign the perm set directly to my user, when I execute the apex callout I get the same exception "We couldn't access the credential(s). You might not have the required permissions, or the external credential "......." might not exist." any ideas?
    – Sam.A.
    Commented Jan 25, 2023 at 19:27
  • 1
    This resolved it for me...and also agreed with you. We lost a whole day of testing on this lol.
    – GeorgeA
    Commented Feb 28, 2023 at 18:03
4

This question gave me a hint, and my problem was solved by granting Read permission to the User External Credentials object via a permission set. Not sure why this isn't documented, but it solved my problem.

Note that I'm also using a flow to kick off the callout via Apex action.

2
  • I'm having trouble navigating the documentation on External Credentials, too :) I believe it's documented here: help.salesforce.com/s/…
    – user38840
    Commented Jan 18, 2023 at 21:08
  • Thanks a lot. Your answer saved my day. Commented Jun 19, 2023 at 12:00
0

In the External Credential you need to create a Principal Parameter in the "Principal" section, after that you need to create a new Permission Set or use an existing one, in the permission set go to the "External Credential Principal Access" and there you can grant access to the External Credential Principal Name that you created in the Principal section of the External Credential, assign the permission set to your user and now you can use the Named Credential

You must log in to answer this question.

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