I have a Legacy Named Credential from UAT that I am porting over to PROD. To test the Named Credential, I am running an Apex Snippet in PROD but I am getting a 401 error. See below: enter image description here

However, when I change the Named Cred to a hard-code of the external site (external Data Cloud org) and with a hard-coded Bearer token, it's working fine. So at least that means the site is not being blocked: enter image description here

Anything else I should check? The Named Cred is authenticated properly. I've tripled check my Auth Provider details, and the Connected App's callback URLs. enter image description here

Auth provider: enter image description here

Connected App(external Data Cloud Org): enter image description here

I feel like I am missing something obvious here but me and my workmates cannot figure it out.

1 Answer 1


Resolved. So it was something obvious. During the Authentication on Named Credential, the account that I used to authenticate was the account for my current org. It was supposed to be the account from the EXTERNAL org.

You must log in to answer this question.

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