I have the following Code in a provider hosted add-in:
using (var userContext = spContext.CreateUserClientContextForSPHost())
{
if (userContext != null)
{
user = userContext.Web.CurrentUser;
userContext.Load(user, cu => cu.LoginName);
userContext.ExecuteQuery();
}
}
This code (using the Tokenhelper) works fine for most of the employees inside our company. So configuration/firewall etc. must be correct.
One single user (we know of) however gets an error on ExecuteQuery():
System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.GetResponse() at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute() at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilde sb)
The user can access the site collection which hosts the app without any problem. Is there maybe a special permission required for retrieving your own login name?
He gets this error on different Browsers. What could be so "special" about this user? Any way to get more detailled Error information? We are currently completely lost where to look at.