Establishing a Connection
Important connection properties
Schema Determines which Sage 200 edition you are connecting to. Specify either StandardUK or ProfessionalUK.
SubscriptionKey provides access to the APIs on Sage 200 that are used to establish a connection. You will first need to log into the Sage 200 API website and subscribe to the API edition that matches your account. You can do so here: https://developer.columbus.sage.com/docs/services/api/uk
Afterwards, the subscription key may be found in your profile after logging into Sage 200.
Authenticating to Sage 200
Sage 200 uses the OAuth authentication standard.
Using OAuth Authentication
OAuth requires the authenticating user to interact with Sage 200 using the browser. The provider facilitates this in various ways as described below.
Instead of connecting with the provider's embedded credentials, you can register an app to obtain the OAuthClientId and OAuthClientSecret.
When to Create a Custom OAuth App
You need to create a custom OAuth app in the web flow.
Creating a custom OAuth app is optional as the provider is already registered with Sage 200 and you can connect with its embedded credentials. Create a custom OAuth app in the following scenarios:
- If you need to request additional permissions over the provider defaults.
- If you want to change the information displayed when users log into the Sage 200 OAuth endpoint to grant permissions to the provider.
Desktop Authentication with a Custom OAuth App
Get an OAuth Access Token
After setting the following, you are ready to connect:
- OAuthClientId: Set this to the Client Id from Sage.
- OAuthClientSecret: Set this to the Secret from Sage.
- Scope: Set this to the Scope from Sage.
- CallbackURL: Set this to the Redirect URL requested from Sage.
- InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- Extracts the access token from the callback URL and authenticates requests.
- Obtains a new access token when the old one expires.
- Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
Creating a Custom OAuth App
To obtain the OAuth client credentials, follow the steps below:
- You must contact Sage to request an an OAuth app be made. Sage offers the following page for contact details: https://developer.columbus.sage.com/contactus
- When making the request, Sage will request you specify the Redirect Url(s). You can request http://localhost:33333 if your application is a desktop app, or a url on your website if making a web app.
- In the response from Sage, they will return the following values: The OAuthClientId as the Client Id, the OAuthClientSecret as the Secret, and the Scope.
Customizing the SSL Configuration
By default, the provider attempts to negotiate SSL/TLS by checking the server's certificate against the system's trusted certificate store. To specify another certificate, see the SSLServerCert property for the available formats to do so.
Connecting Through a Firewall or Proxy
To connect through the Windows system proxy, you do not need to set any additional connection properties. To connect to other proxies, set ProxyAutoDetect to false.
In addition, to authenticate to an HTTP proxy, set ProxyAuthScheme, ProxyUser, and ProxyPassword, in addition to ProxyServer and ProxyPort.
Set the following properties:
- To use a proxy-based firewall, set FirewallType, FirewallServer, and FirewallPort.
- To tunnel the connection, set FirewallType to TUNNEL.
- To authenticate, specify FirewallUser and FirewallPassword.
- To authenticate to a SOCKS proxy, additionally set FirewallType to SOCKS5.
Troubleshooting the Connection
To show provider activity from query execution to network traffic, use Logfile and Verbosity. The examples of common connection errors below show how to use these properties to get more context. Contact the support team for help tracing the source of an error or circumventing a performance issue.
- Authentication errors: Typically, recording a Logfile at Verbosity 4 is necessary to get full details on an authentication error.
- Queries time out: A server that takes too long to respond will exceed the provider's client-side timeout. Often, setting the Timeout property to a higher value will avoid a connection error. Another option is to disable the timeout by setting the property to 0. Setting Verbosity to 2 will show where the time is being spent.
- The certificate presented by the server cannot be validated: This error indicates that the provider cannot validate the server's certificate through the chain of trust. If you are using a self-signed certificate, there is only one certificate in the chain.
To resolve this error, you must verify yourself that the certificate can be trusted and specify to the provider that you trust the certificate. One way you can specify that you trust a certificate is to add the certificate to the trusted system store; another is to set SSLServerCert.
- CompanyId: The specific company to connect to. It should only be set if you have multiple companies. The CompanyId should be sent to you by Sage when each company is created.