ShinojKumar on Tue, 11 Apr 2017 07:15:28
We have a provider hosted app deployed on AWS(.net code). On SharePoint Dedicated tenant environment everything was working as expected.
But now the environment has been moved to O365 Vnext. . Apps are not working in new environment!
Attaching the error herewith.
Kindly Share your thoughts!
Server Error in '/QA' Application.
The remote server returned an error: (401) Unauthorized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote server returned an error: (401) Unauthorized.
|An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.|
[WebException: The remote server returned an error: (401) Unauthorized.]
Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb) +975
Philips.HRDCAppsWeb.HelperClasses.NewsItemHelper.GetNewsItems(String& duration) +2930
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34280
Lee__li on Wed, 12 Apr 2017 02:24:37
Have you updated the client id & secret of your add-in for new o365 environment?
You could check below threads for similar issue.
What’s more, here is one link about how to create and deploy provider hosted app for your reference:
Vivek Jagga on Wed, 12 Apr 2017 05:20:35
Error 401 is only for authirization, it seems that you have not updated the ClientID and Client Secret Id in your Azure / AWS app settings.
You have to use the same key at the time of registration of app in your environment.
there might be a chance that you have missed to update ClientId and ClientSecretID and your app fetch these details from your web.config file of your app.
ShinojKumar on Wed, 12 Apr 2017 11:12:23
Thanks for you reply. I have few questions.
1. Sites are geting migrated to O365 Environment. All the existing Librararies, lists , contents are successfullly migrated. What about appcatalog site?
2.I created new client Id and secret from apprenew.aspx and updated in config file. Any changes expected in tokenhelper.cs or SharePointcontext.cs files
3. Will Hightrust or Low trust will matter here? as we are having below snippet
SharePointContextProvider.current = new SharePointAcsContextProvider();
SharePointContextProvider.current = new SharePointHighTrustContextProvider();
ShinojKumar on Wed, 12 Apr 2017 11:19:14
Thanks for responding!
Yes I did. Updated client Id and Secret. We are hosting app's .net code on Amazon server. I am little confused about uploading .app file in new environment's app catalog site. I mentioned this thing in reply to Lee's response.
Anything special to be taken care for O365 Site-amazon server connection or does it work exactly like in Azure?
Lee__li on Wed, 19 Apr 2017 03:51:19
I would suggest you check does your app exists in app catalog site manually.
Go to Admin center->Admin->SharePoint->apps->App Catalog->Apps for SharePoint
You could check below thread for reference.
We can use Low trust app in SharePoint online only, when you update the client Id and secret for your app, make sure you update these values in app Web.config.
Here is the guideline for your reference.
Make sure the app new ClientId exists in /_layouts/15/AppPrincipals.aspx.(after you updating your app instance in specific site)
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact email@example.com
Lee__li on Tue, 25 Apr 2017 05:15:26
I am checking to see how things are going there on this issue. Please let us know if you would like further assistance.
You can mark the helpful post as answer to help other community members find the helpful information quickly.
You can also share your own solution here and mark it as answer, and we can learn from each other.