function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sirkidsirkid 

Authorization Required

Hi Guys,

I have a page on my force.com sites. One of page has a problem:

 

try
            {
                chargeResult = ChargentSFA.TChargentOperations.ChargeOpportunity_Click(Order.Id);
            }
            catch(Exception ex)
            {
                ApexPages.addMessages(ex);
                errorMessage = ex.getMessage();
                return Page.OrderCreated;
            }

 

I invoked the Chargent package to do some payment operations here. That's fine. But if any exceptions occured, it was caught by the catch block. But there will be an error messages says: Authorization Required. Seems my exception was not caught. Actually, I checked the debug log, the exception was caught properly.

 

Anybody has seen the same errors? If an exception occured, no matter it was caught or not, it will be redirected to the "Authorization Required" page. Why?

Help!

Best Answer chosen by Admin (Salesforce Developers) 
BulentBulent

We do hear you folks! 

We will work on this to get it better.

 

at the mean time you might want to create a profile that matches the site public access settings and login with a user who has this profile and test your page. In this way you will see the exact error on the ui. 

All Answers

WesNolte__cWesNolte__c

Hey

 

Does the page that you navigation to (i.e. Page.OrderCreated) require a non-null value of the chargeResult variable? Or some parms perhaps? What happens if you drop the URL straight to Page.OrderCreated into your Sites URL? Do you get an error?

 

Wes 

slaneslane
Is your Exception page part of the Site Pages list? Meaning, has it been added to the site such that it can be accessed without authentication?
LaurentDelcLaurentDelc

Hi everyone,

 

I have kind of the same problem. When an uncaught exception happens, the user is brought to a Authorization required.

I have the Exception page in my site profile (it was my first intuition) but still, i doesn't give me any idea of why I got an error.

Can't we at least modify this page so that it tells us why? and what exactly we don't have access to? It is really annoying to have this page and have to guess what happened....

 

Laurent 

slaneslane

Laurent:

 

You can edit the page yourself, to add additional information. I found it useful to add in another value, I believe it was Site.ErrorDescription, to get more detail on errors.

LaurentDelcLaurentDelc

Well that's what I did, but I only get a Unauthorized exception (what a surprise!) but without anymore explanation:

- I don't see any log

- I don't see the reason of this Exception or what I didn't have access to.

 

Which means I have no way to find the reason of this exception.

 

Any idea? 

BulentBulent

Exception error page is only used when users are authenticated via the portals.

on the public site we do not show the error massages. 

 

If you are getting authorization required page then it might means the following things:

1-site doesn't have the right level permission for the objects

2-site doesn't have the right level field level visibility

3-private sharing is enabled and site doesn;t have access to the related record

4-objects might not be deployed yet

5-visitor is trying to access a visualforce page that is not enabled for site  

LaurentDelcLaurentDelc

Alright for the message, it makes sense not to show too much to the Site user.


But while developing we shouldn't have to GUESS the cause of an error. Imagine guessing when you develop a 1000 lines controller....

 

Why don't we have the proper logs? How can we get the reason of this exception, especially the EXACT resource that we don't have access to. It shouldn't be difficult to get that. Maybe with a special controller that displays some debug, or at the worst sends an email with the full logs?

 

Thanks for the quick answer

 

Laurent 

 

 

WesNolte__cWesNolte__c

Mr Laurent whom I do not know at all. Please see the idea listed in this post and vote for it. Get your friends and family to vote for it. Get your little french poodle to vote for it.

 

Wes

LaurentDelcLaurentDelc

Well Mr Wes whom I do not know either at all,

 

I have voted for this idea. And actually I made... sorry proposed my fellow team partners to vote for it. I don't know about my family though.

 

I am hating Site development right now, but I guess it will get better after some wine and cheese.

 

Regards 

LaurentDelcLaurentDelc

One simple idea that worked for me:

Simply replace the Site URL by your backoffice URL. It will display the error message.

 

I know it won't work for everybody but it saved my life right now.

 

Laurent 

BulentBulent

We do hear you folks! 

We will work on this to get it better.

 

at the mean time you might want to create a profile that matches the site public access settings and login with a user who has this profile and test your page. In this way you will see the exact error on the ui. 

This was selected as the best answer
NFPGardenAdmin1NFPGardenAdmin1

I have a similar problem; however, none of the 5 options seem to apply to my case.  I am trying to display data, and in fact do display this data on one Page.  One a seperate page, I try to display the same data, but am unable to and receive the auth required page.

 

I clearly have access to the data because I have displayed it on other pages - pages connected to this page.

 

Any suggestions?

SteveAtGFISteveAtGFI

Bulent - is this due to "get better" anytime soon? This is painfully frustrating to troubleshoot.

Ramesh SomalagariRamesh Somalagari
I have same problem it asking "Authorization Required".Please click this url https://developer.salesforce.com/forums/#!/feedtype=SINGLE_QUESTION_DETAIL&dc=Mobile&criteria=ALLQUESTIONS&id=906F0000000AZYGIA4 (https://developer.salesforce.com/forums/#!/feedtype=SINGLE_QUESTION_DETAIL&dc=Mobile&criteria=ALLQUESTIONS&id=906F0000000AZYGIA4)