Concretio

View Original

Debugging Sites Authorization Required Error !

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.

See this content in the original post

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/