Symptoms
Whent trying to access a certain form which contains a SharePoint list view in runtime mode, the user receives an error:
Failed to initialize the Context: URL: https://....
Username: Error Details: The remote Server returned an error: (401) Unauthorized. Method: SharePointService.InitializeContext
Detail: Method - GetSmartObjectReader
Module: SourceCode.SmartObjects.Client.dll
Another user with the same user rights in the System doesn't receive this error message.
Diagnosis
This is a SharePoint issue and you first need to login with your user to the SharePoint site before K2 will be able to connect.
See this KB article about deleting the OAuth Token from the K2 database for additional details on this issue:
KB001627 – Known Issue when using OAuth with On-Premises SharePoint Farms
Workarounds for this issue:
1) Please check whether or not the user is added directly to the list of permissions of this site collection or is added as part of a group? If he is in a SP Group, then please add him directly to the list of permissions. This is a known issue in SP2013. Add the user directly to a SP group (it should have read/write permissions as per this pre-requisite:
http://help.k2.com/KB001645.aspx
There is the "Sync Users/Groups" button in the K2 App Settings page you can click as well to sync these things.
2) Put a "Content" control on your SmartForm and make it hidden, point it to your SharePoint site collection URL
3) Make sure the user has been added to SP (as per 1 above) and run a User Profile Sync - Full Sync on SharePoint Central Admin
Resolution
See Diagnoses section.