Tuesday, March 12, 2013

SharePoint2013 providerhosted app with ACS error : The parameter 'token' cannot be a null or empty string

Scenario: Today when I hosted ProviderHosted app web application (stand alone ASP.Net web application which is part of the ProviderHosted app solution) on a remote machine and installed or added the app (.app) on a SharePoint farm I have been greeted with following error.

Error message while navigating to a remote machine on which ProviderHosted app web application is hosted:-
The parameter 'token' cannot be a null or empty string.

Following is the welcome error message, when I click on the ProviderHosted app from SharePoint farm/site:-

Resolution: Although similar error message is shown for several other reasons, looking at these things may help you fix the issue. Basically you need internet access on a remote machine on which you are hosting the ProviderHosted app web application, so that it can talk to ACS and get the context token, access token, refresh token and also talk back to SharePoint farm to get host web properties of a SharePoint site like: site title, site lists, logged-in user etc.

 Based on how your environment and DNS setting are configured. You might have to add the following section (in case you do not have internet connectivity on remote machine) to remote ProviderHosted app web application's web.config (stand alone ASP.Net web application which is part of the ProviderHosted app solution) hosted on remote machine.

<system.net>
<defaultProxy>
<proxy usesystemdefault="True"
proxyaddress="http://internetaccessProxySite.com"/>
<bypasslist>
<add address="https://mysharepointsite.com"></add>

</bypasslist>
 </defaultProxy>
<system.net>


Remove/comment the complete <system.serviceModel> section in web.config of remote Providerhosted app web application.


Make sure that the current logged-in user has  required permissions to the SharePoint site. Else it may throw access denied error when your remote app web is trying to read SharePoint data.       

No comments:

Post a Comment