+ Start a Discussion

Developer Guide: Sites example: Authorization Required issue



I followed the steps in the Developer Guide. The default site is accessible but when I click on the Position ID to go to the PublicJobDetails page, I am taken to the 'Authorization Required - You must first login in or register before accessing this page. 


The visualforce page has been added to the Site and Custom Object Permissions have been granted to Site Users. 


Message Edited by sumu on 04-29-2009 12:53 PM
Best Answer chosen by Admin (Salesforce Developers) 

seems like we have a bug related to using the {!$Site.Template} with a standard controller together.

As a workaround use the actual template page name rather than the expression, until we fix the issue 

All Answers

make sure Field level security is set as visible in public access settings for the fields you are exposing on that object

Field level security has been set to 'Visible' for the Default Site Profile



If I found the correct site I see that you are getting site is in maintenance page not authorization required.
again if that's the corect site  the reason for this is that your site has a path called "/default" however your link to the detail page doesn't have a path
and it's trying to find the "PublicConfDetails?id=xxx" under the root site which doesn't exist
update that link with the site expression for the path like "{!$Site.Prefix}/PublicConfDetails?id=xxx" 

Message Edited by Bulent on 10-03-2009 12:54 PM
I have taken off the 'default' from the Site URL and made the change that you recommended. Still getting the same issue - 'Authorization Required'

seems like we have a bug related to using the {!$Site.Template} with a standard controller together.

As a workaround use the actual template page name rather than the expression, until we fix the issue 

This was selected as the best answer

Thanks a bunch. That worked. 


Was the bug fixed?


I have a similar problem. I didn't understand the solution very well, what do you mean with "using the actual template page"? here is my code:


<apex:page sidebar="false" showheader="false" controller="RegisterWebinarsController"> <style> body { font-family: Arial Unicode MS; }</style> <apex:form id="webinarsForm"> <apex:outputText style="font-weight: bold;font-size:150%;" value="User Registration"/> <apex:pageMessages id="error" /> <apex:panelGrid columns="2" style="margin-top:1em;"> <apex:outputLabel value="First Name:" for="firstname" /> <apex:inputText id="firstname" value="{!lead.firstname}" /> <apex:outputLabel value="Last Name:" for="lastname" /> <apex:inputText id="lastname" value="{!lead.lastname}" /> <apex:outputLabel value="Email:" for="email" /> <apex:inputText id="email" value="{!lead.email}" /> </apex:panelGrid> <br /> <apex:commandButton value="Continue" action="{!goToConnectPro}"/> <br /> </apex:form> </apex:page>

And the standardController:



public with sharing class RegisterWebinarsController { Lead lead; public Lead getLead() { if(lead == null) lead = new Lead(); return lead; } public PageReference goToConnectPro() { createNewWebinar(); PageReference webinars = new PageReference('https://webinar.company.com'); return webinars; } public void createNewWebinar(){ System.debug(lead); lead.site_ID__c = 'ost'; lead.Company = 'NA'; insert lead; } }

I can see the site and the form but I get the Authorization required when I click on the button.

I gave public permissions to the user to "read" and "create" leads but still the same error:


Authorization Required

You must first log in or register before accessing this page.
If you have forgotten your password, click Forgot Password to reset it.


What else I can do?


please help!


Ignore me, this was all due to a validation rule in Leads that was failing and by the default the Authorization Required message was displayed. I changed the code to catch the exception and then I found the problem and solved it.

Ron WildRon Wild

We were hoping this bug would be fixed in the Winter '10 release.  It looks like it was not.   Any estimate on when it will be corrected?


We have product features that depend on this that are on hold. 


To make the solution more explicit: If your template page is called "MySiteTemplate", then your composition tag should look like this:



<apex:composition template="MySiteTemplate">

 instead of this:

<apex:composition template="{!$Site.Template}">





Message Edited by jlo on 11-05-2009 10:31 AM

I have the same issue with trying to deplay a Force.com site in conjunction with Groundwire's Volunteer package. Same errors.


Currently, you can't reference unmanaged components and resource files from the template if you are displaying a managed page.   


However, as you might have guessed, you can replace the {!URLFOR($Resource......    tags with the actual URL of your files.  (If the resource is a zip file, you can't of course).


AND .... if you create your own managed package in a developer org with all the resource files and components you want to reference in your template, those will work as well.   Because they will then have a package prefix  (e.g. mypkg__   )