1

I want a Site Guest User to be able to hit a page that uses Apex to do an API call. However, if I create a Named Credential of type 'Named Principal', then that credential is simply missing from the list of available credentials when you try to grant guest profile access.

If I make it a 'Per User' named credential, then it appears in the list of credentials I can give access to that user, however there is nowhere I can go to set the password for that user. Normal users can login and set it themselves, but a guest user by definition cannot.

How on earth do I do this?

7
  • The Identity Type is actually meant to define whether the API needs user specific information or not- help.salesforce.com/… If your API needs to be accessed from a site, i'm guessing per-user is not really an option. Anything from Named Principal or Anonymous should work. Do you come across a specific error on your site ? Please post the information more specific to the issue to get better help.
    – Nagen Sahu
    Oct 20, 2020 at 9:29
  • The specific error I get is on the line of code where it tries to merge the password from the Named Credential into a header field. It immediately gives the end user the 'You must be authenticated' page. If I change my Named Credential to be a Named Principal then I cannot grant the Site Guest User access to it. It simply does not appear in the list.
    – Chris KL
    Oct 21, 2020 at 1:40
  • Does your external service require Username and password to be supplied to it ? In that case it would be better if you use Named principal and add the Headers programmatically with fixed username and password values. developer.salesforce.com/docs/atlas.en-us.apexcode.meta/…
    – Nagen Sahu
    Oct 21, 2020 at 6:08
  • I could do that, but I was hoping to store the password securely in the Named Credential, rather than somewhere else :(
    – Chris KL
    Oct 21, 2020 at 7:31
  • You can store a username and password with Named Principal some explanation here - sfdcfanboy.com/2018/01/15/named-credentials-setup Make sure to check the Generate Authorization Header
    – Nagen Sahu
    Oct 21, 2020 at 20:09

0

Your Answer

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

Browse other questions tagged or ask your own question.