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
Larry KlugerLarry Kluger 

Showing error messages from a Custom Authentication Provider Plug-in

I wrote a Custom Authentication Provider Plug-in for OAuth authentication with a SAAS service. It works fine. 

Question: How do I give error messages to the user if there is a problem during the OAuth authentication and authorization dance? Eg if the client id or secret is wrong. Or if the user declined to authorize the app when asked? 


PS. pages that were helpful:
aperpages.addMessage('your error message');

ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.error,.'your error message'));
Larry KlugerLarry Kluger
Unfortunately the suggested answer was not right. I received the error message: "ApexPages.addMessage can only be called from a Visualforce page" 

As I said in my question, the potential errors will occur during the processing of an Apex class that I wrote that provides Custom Authentication for Auth. Providers. Any other ideas? Many thanks.