Issue
When trying to activate the Exchange feature through K2 Management, the following is shown:
Error Code
The error looks as follows: "Error occurred trying to get a token for the current user. Unable to connect to the remote server" on the Oauth token step."
Additional information from the browser and the Hostserver log files:
"2364338498","2021-02-25 16:29:30","Error","System","2025","InternalMarshalError","SourceCode.Hosting.Server.Runtime.HostServerBroker.InternalMarshal","2025 Error Marshalling SourceCode.Security.OAuth.OAuthManagement.DoOAuthTokenExchange, Unable to connect to the remote server
"2364338921","2021-02-25 16:30:07","Error","MessageBus","61012","ConnectionError","ExchangeWebServicesOrigin","61012 Exception from message [email address]: Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException: The Autodiscover service couldn't be located.
Resolution
In our case, the client's K2 Server was not able to access these URL's:
Once they allowed the K2 Server to reach these applicable URL's, the problem no longer occurred.
Additional Information
Additionally in our investigation, we made sure of the following:
- In K2 Management > K2 Management > Authentication > OAuth > Resources
- Confirm the Authorization Endpoint, Token Endpoint and Token value (entity_Id) is correct, and has the correct format:
https://trust.k2.com/{tenant_id}/authorize/oauth/2/request
https://trust.k2.com/{tenant_id}/token/oauth/2
- In the K2HostServer.exe.config file make sure the AAD Smartactions account is configured correctly under the "system self" section.
- Make sure that the same Smartactions account is configured in the "sendemailfrom" correctly.
- In the ConnectionStringEditor.exe tool, make sure the OAuthResource and OAuthResourceAudience values are correct according to the value (s) in the following section for Exchange: K2 Management > K2 Management > Auth > OAuth > Resources.
- Make sure Auto Discover is enabled in the ConnectionStringEditor.exe tool and that the activation was completed by the Global administrator in Office 365.