I'm looking into using Named Credentials (spring '15) to simplify apex callouts to an external web service. I actually thought, based on the documentation, that this would help, and I'm referring correctly to the Named Credential in my code and have also given my profile access to the NC, but I'm faced with this error when I do the callout:

System.UnexpectedException: You don't have permission to view this data. Ask your administrator to set up authentication for the external data source

This seems to say that NC are tied to the use of External Data Source, which is absolutely unrelated to what I want to do, and the documentation doesn't mention that they are a requirement. Have any of you run into this error when testing out Named Credentials?


The error occurs if your named credential is configured to use per-user authentication but the currently logged in user that is trying to use the named credential (or their administrator) has not added their credentials to the Authentication Settings for External Systems section (located under My Settings) for that named credential.

The error message mentions external data sources because under the hood, the features share a lot of the same code. But it is confusing, and a bug.

| improve this answer | |
  • 1
    yeah, I figured as much that this was a wrong functional error message. i filed a bug report (case) with Salesforce so they know about it. – akarnid Dec 17 '15 at 13:56

Thanks for the answer, just to help. In my tests, what Lawrence pointed is strictly necessary and those are the credentials that will be used by Salesforce to authenticate to the remote site. Those defined on the named credenctial (per user password authentication) are not used. If you want to verify that, use any wrong credentials on the named credentials definition, but use the correct ones on the Authentication Settings for External Systems section (located under My Settings) and you will see as the connection is established correctly.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.