TransWikia.com

Authorization Required on public Site

Salesforce Asked by user2610036 on January 20, 2021

I’m currently trying to create a public site but am running into an issue where whenever I try access any data I get the ‘Authorization Required’

A simple test was to create a basic VF page

<apex:page standardController="Account">
    {!Account.Name}
</apex:page>

The guest site profile has read write access on the Account object
Every field on Account has its visibility flag ticked

If you visit the page /site/test it shows nothing which is what I would expect
but give it an id /site/test?id= and it shows the ‘Authorization Required’

So right now I am at a loss. I’ve given the site profile all the permissions it needs and the visualforce page is configured correct for the site since you can view the VF page when it is not trying to access an Account.

Is there some config somewhere that I am missing?

3 Answers

The "authentication required" error happens when the site user experiences an error, such as not having permission to a field, a null-pointer exception, etc.

  1. Try using the debug logs for the sites user. Setup > Monitoring > Debug Logs, enable the sites user, generate the error, and check the logs.
  2. Turn on development mode for your admin user (Setup > Personal Information) and try viewing the page. You might be able to see the error directly (assuming this is a code problem and not a security issue).
  3. Setup an alternate Visualforce page to capture the error from the first page, and return the errors back to that page.

More details can be found here: Debugging Sites Authorization Required Error.

Answered by Jorge Valdés on January 20, 2021

Two steps:

  1. First go to Setup write VisualForce pages" and reach to VF page list. Here you will find the page you need to access.

    • Click on Preview for Webpage. The web page will open in separate window. Access this from your profile and not from guest user. There you can see errors with specific name of the object. For example if it is not able to access an object. It will mention the name of object that is seeking permissions.
  2. Go to Setup

    • type Domain in quick find.
    • Click on "Custom URLs"
    • Next you will find sites details click on Site label. It will lead to all details for site.
    • Click on button Public Access Settings that will open profile access page.
    • Click on App section
    • Click on Object Settings (we are assuming we have an object access problem, which is most often the case.)
    • That will open all Objects page, now you have select object accessed by visual force page in question or object identified in first step.
    • So it now simply Profile OverviewObject Settings  Selected object name (let's say Accounts)
    • Click on Edit and give read and write access
    • Click save.

Now try your app again. I hope then Authorization problem gets resolved.

Answered by Ankur Rana on January 20, 2021

You can not have access to Account from a public site when you use standard controller, only if the guest user has created the account which is not the case for you. That's Salesforce standard security. You will have probably to create a custom controller set as 'public without sharing' or 'global'.

Answered by Cloud Ninja on January 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP