Symptoms
During package deployment the majority of K2 artifacts gets deployed without issues, but the following error occur for User Service Object:
Fail User Service Object : OAuth token requires authorization. OAuth token requires authorization. SourceCode.Hosting.Exceptions.AuthenticationException: OAuth token requires authorization. at SourceCode.Hosting.Server.Runtime.HostServerBroker.InternalMarshal(String TypeName, String MethodName, Objectj] ParamArray, Booleanl] NullList, Boolean UseSession, String SessionCookie, String RemoteConnectionString) at SourceCode.Hosting.Server.Runtime.HostServerBroker.SessionMarshal(String TypeName, String MethodName, Objectj] ParamArray, String SessionCookie) at SourceCode.Runtime.Services.SmartObjects.ServerAccessLayer.ExecuteSessionMarshal(String serverTypeName, String methodName, Objectj] parameters) at SourceCode.Runtime.Services.SmartObjects.ServerAccessLayer.DeployServiceObject(Guid serviceInstanceGuid, IServiceObject serviceObject, String serviceObjectXml, Boolean isExtendible) at SourceCode.Runtime.Services.SmartObjects.ServiceObjectDeploymentItem.DeployItem(IQueryContext queryContext, Stream stream, ComplexType complexType) at SourceCode.Runtime.Services.SmartObjects.RuntimeService.Deploy(IDeploymentContext context) at SourceCode.Deployment.Runtime.ServerSession.BeginDeploy()
Diagnoses
As error message suggests the issue here is that OAuth tokens are not authorized anymore and has to be reauthorized.
Resolution
To re-authorize OAuth token run the SmartObject Tester Utility as K2 Service Account user and perform the following steps:
1. Run SmartObject Service Tester on K2 App Server
2. Go to SmartObject Explorer > Azure Active Directory > iSite Name] > Users > Execute
3. Try to search for a user
4. A popup will appear saying to try again after logging in
5. A new browser window will appear for you to login to Office365
6. Use the SharePoint Admin account to login
7. A page will appear prompting you to allow K2 to access Office365
8. Once accepted, the next page will show Authorization Successful
Run the Package and Deployment Tool as the Service Account and try to deploy again to make sure that issue has been resolved.