Unable to debug my remote event receiver using ngrok.Error "Localhost is not the intended audience”"

Steel Contributor

I want to debug our remote event receiver for a sharepoint online site collection. and since the azure service bus appraoch for debugging RER is not supported anymore. so i am trying to use the ngrok appraoch. I did these steps:-

 

1- Inside Visual Studio 2015 >> create new sharepoint add-in >> type provider-hosted Add-in >> I enter the url for a test enterprise wiki site collection which have the Sideloading of apps feature enabled. enter image description here

 

2- Then i enabled the handle Add-in installed/uninstalled:- enter image description here

3- Then inside the AppEventReceiver.svc i entered code this code + the methods implementation:-

public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
         {
             SPRemoteEventResult result = new SPRemoteEventResult();

         switch (properties.EventType)
         {
             case SPRemoteEventType.AppInstalled:
                 HandleAppInstalled(properties);
                 break;
             case SPRemoteEventType.AppUninstalling:
                HandleAppUninstalling(properties);
                 break;
             case SPRemoteEventType.ItemAdded:
                 HandleItemAdded(properties);
                 break;
         }


         return result;
     }
     // code goes here for the above methods implementation ..

For debugging the RER, I did these steps:-

1- I run this ngrok command:-

ngrok http --host-header=rewrite 54001// where this port is our RER port inside visual studio

2- Update the Update web.config, with the url i got from the above command:- enter image description here

3- Set the web application as Start Up project.

4- Navigate to the ngrok url where i got this page:- enter image description here

5- Register the app and update the web.config with the generated ClientId + ClientSecret enter image description hereenter image description here

6- After that i run the Visual Studio project >> i got this message to trust the app:- enter image description here

7- Where the app start showing inside the site content page with a message that it is been added...

8- After that my code reached this break point:- enter image description here

9- But inside the TokenHelper.cs , I got this exception**:-

An exception of type 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException'occurred in ****Web.dll but was not handled in user code Additional information: "localhost" is not the intended audience "f15f8358-54c4-4767-95b2-98051ed0b1c5/00af9b86.ngrok.io@8208ba41-935e-4b54-ace7-

 

on this code:- enter image description here

so can anyone advice on this please?

2 Replies

Hello @john john,

 

I'm starting a new provider-hosted Add-in RER project and I want to use Ngrok to debug.

 

Were you able to solve your problem? I don't want to put to much work on a project that I won't be able to debug...

 

Thanks,

Chris

 


@Chris600 wrote:

Hello @john john,

 

I'm starting a new provider-hosted Add-in RER project and I want to use Ngrok to debug.

 

Were you able to solve your problem? I don't want to put to much work on a project that I won't be able to debug...

 

Thanks,

Chris


@Chris600i have not used Ngrok before, so i can not tell if you will be able to debug your RER using it or not.... but still i can not debug my RER using azure service bus (which suppose to work well, even VS have a place to define the service bus url !!!)