Thursday, August 16, 2012

Authorization Issue with Sites on Force.com

One of the most annoying things in any development is authorization errors.  The problem multiplies itself when there is no stack trace on where the authorization errors are coming.  Last couple of days we ran into a bunch of Unauthorized errors while accessing, Visualforce pages on public sites.

Today finally was able find the root cause.  The issue was one of the columns referred in the SOQL belongs to the parent object and the object did not have access

Since, Salesforce does not display any error or where exactly this issue is here are few ways I think would help you to quickly identify the root cause


  • Enable debugging for the sites users
  • Check the debug logs and look for the log just before the authorization error
  • Go to the bottom of the log and trace back the code
    • One of the easier ways to find the issue is to add debug statements at different points where you think the most probable cause of failure could be
  • Check of the statement that last executed
  • Verify if the statement is the last statement in the method (apex code)
  • If you don't see that it is the last statement, then the failure just occurred at the statement
  • If the issue is with the SOQL, see that the columns being queried in the SOQL have access to the Force.com sites

Hopefully these steps will expedite the authorization issues you would encounter.  Let me know if you  found variations of this issue

No comments:

Post a Comment