SharePoint Provider-Hosted App - 401 Unauthorized error on clientContext.ExecuteQuery()

So you are ready to develop a SharePoint app and have followed this MSDN article to get everything set up. F5 in visual studio, clicked Trust It to "Do you trust <name of your app>?" from SharePoint, and then you are getting 

The remote server returned an error: (401) Unauthorized


Chances are the IssuerId in provider-hosted application web.config is listed as a UPPER CASE Guid string. 



Offline install of Office Developer Tools for Visual Studio 2012

Last week Microsoft has released the RTM version of Office Developer Tools for Visual Studio 2012. This is a very exciting news for those SharePoint 2013 developers who has been using Preview 2 version of the tool (made to GA on Nov/2012) since SharePoint 2013 RTM.

For those who don’t need to worry about the offline installation and just want to install it on one or two development machines – here is the link to download and install directly through Microsoft’s Web Platform Installer (Web PI) http://aka.ms/OfficeDevToolsForVS2012

However, please continue reading if you like to:

1. keep a shadow copy of whole installation package along with all the pre-requirements components

2. able to install Office Developer Tools for Visual Studio 2012 in one or more offline environments

3. save some internet bandwidth for your enterprise network

Here is what you need to do:

*You will need a PC with Microsoft Web Platform Installer 4.5 installed and connected to the internet to download the initial copy of whole package.

Step 1. Download the Package through WebpiCmd.exe command (Online)

From the Web PI wizard you can see there are multiple dependency components needs to be installed as part of Microsoft Office Developer Tools for Visual Studio 2012




Here is the WebpiCmd command that you can use to avoid  to download each these dependencies one by one manually.

*WebpiCmd is locate at “C:\Program Files\Microsoft\Web Platform Installer” on the machine that has Web PI 4.5 installed

WebpiCmd.exe /offline /products:OfficeToolsForVS2012RTW /Path:C:\YourFolder\OfficeToolsForVS2012RTW