Debugging Sites Authorization Required Error !

CEO

Force.com sites redirects to “Authorization Required” page in case something goes wrong behind the scenes, for ex.

  • The Site’s public access settings or user profile doesn’t have access to a Page, Object, field etc used in the visualforce page / controller.

  • In case of Apex Exceptions like, LimitException.

  • Etc

“Unauthorized” page makes sense in case of missing access problem. But in case of Exceptions ideally the redirect should be the “Exception” page.

image

Next we will see approaches to debug the cause of this issue.

Debug Approach 1

The first approach to debug this problem would be to 

  • Enable debugging for “Sites User”, under Setup > Monitoring > Debug Logs.

  • Refresh the page failing for “Authorization” error.

  • Check what comes in debug logs.

The above approach will work most of the time and will let developers know, why “Authorization Required” page is shown. In our case, debug logs clearly say “DML currently not allowed”, as shown in screen shot below.

Read More: https://abhinav.fyi/debugging-sites-authorization-required-error/

Abhinav Gupta

First Indian Salesforce MVP, rewarded Eight times in a row, has been blogging about Salesforce, Cloud, AI, & Web3 since 2011. Founded 1st Salesforce Dreamin event in India, called “Jaipur Dev Fest”. A seasoned speaker at Dreamforce, Dreamin events, & local meets. Author of many popular GitHub repos featured in official Salesforce blogs, newsletters, and books.

https://abhinav.fyi
Previous
Previous

Understanding–“No such column on entity 'Name'” Error !

Next
Next

Apex Test data isolation from Org/User’s data.. !