JDBC Driver for Reckon Accounts Hosted

Build 22.0.8462

Establishing a Connection

Creating a JDBC Data Source

You can create a JDBC data source to connect from your Java application. Creating a JDBC data source based on the CData JDBC Driver for Reckon Accounts Hosted consists of three basic steps:

  • Add the driver JAR file to the classpath. The JAR file is located in the lib subfolder of the installation directory. Note that the .lic file must be located in the same folder as the JAR file.
  • Provide the driver class. For example:
    cdata.jdbc.reckonaccountshosted.ReckonAccountsHostedDriver
  • Provide the JDBC URL. For example:
    jdbc:reckonaccountshosted:SubscriptionKey=test;CountryVersion=2021.R2.AU;CompanyFile=Q:/CData Software.QBW;User=test;Password=test;InitiateOAuth=GETANDREFRESH;CallbackURL=http://localhost:33333;OAuthClientId=MyOAuthClientID;OAuthClientSecret=MyOAuthClientSecret;
    
    or
    
    jdbc:cdata:reckonaccountshosted:SubscriptionKey=test;CountryVersion=2021.R2.AU;CompanyFile=Q:/CData Software.QBW;User=test;Password=test;InitiateOAuth=GETANDREFRESH;CallbackURL=http://localhost:33333;OAuthClientId=MyOAuthClientID;OAuthClientSecret=MyOAuthClientSecret;

    The second format above can be used whenever there is a conflict in your application between drivers using the same URL format to ensure you are using the CData driver. The URL must start with either "jdbc:reckonaccountshosted:" or "jdbc:cdata:reckonaccountshosted:" and can include any of the connection properties in name-value pairs separated with semicolons.

Connecting to Reckon Accounts Hosted

The driver makes requests to Reckon Accounts Hosted through OAuth. Specify the following connection properties:

  • User: Required. The username of the company file.
  • Password: Required. The password of the company file.
  • CompanyFile: Required. The path to the company file.
  • InitiateOAuth: Set this to GETANDREFRESH to let the driver handle access tokens.
  • CountryVersion: Defaults to 2021.R2.AU.

You can also create a custom OAuth application, and then specify the following additional connection properties:

  • SubscriptionKey: API Key retrieved from Reckon Portal on the Azure Platform.
  • OAuthClientId: Set to the Client ID in your app settings.
  • OAuthClientSecret: Set to the Client Secret in your app settings.
  • CallbackURL: The redirect URI of your Custom OAuth App.

Desktop Authentication

CData provides an embedded OAuth application that simplifies OAuth desktop authentication. Alternatively, you can create a custom application. See Creating a Custom OAuth App for information on creating custom applications and reasons for doing so.

For authentication, the only difference between the two methods is that you must set two additional properties in custom applications.

With embedded OAuth you can connect without your user credentials, whereas custom applications require that you specify Client Id and Client Secret properties. After setting the following, you are ready to connect:

  1. InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
  2. AuthScheme: Set this to OAuth.
  3. OAuthClientId: Set to the Client ID in your app settings.*
  4. OAuthClientSecret: Set to the Client Secret in your app settings.*
* Only required when using a custom application.

When you connect the driver opens the OAuth endpoint in your default browser. Log in and grant permissions to the application. The driver then completes the OAuth process as follows:

  • 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 that persist across connections.

Web Authentication with your Custom OAuth App

When connecting via a Web application, you need to register a custom OAuth app with Reckon Accounts Hosted. See Creating a Custom OAuth Appfor information about creating custom applications. You can then use the driver to get and manage the OAuth token values. Get an OAuth Access Token

Set the following connection properties to obtain the OAuthAccessToken:

  • OAuthClientId: Set this to the Client Id in your app settings.
  • OAuthClientSecret: Set this to the Client Secret in your app settings.

You can then call stored procedures to complete the OAuth exchange:

  1. Call the GetOAuthAuthorizationURL stored procedure. Set the AuthMode input to WEB and set the CallbackURL input to the Redirect URI you specified in your app settings. If necessary, set the Permissions parameter to request custom permissions.

    The stored procedure returns the URL to the OAuth endpoint.

  2. Open the URL, log in, and authorize the application. You are redirected back to the callback URL.
  3. Call the GetOAuthAccessToken stored procedure. Set the AuthMode input to WEB. Set the Verifier input to the "code" parameter in the query string of the callback URL. If necessary, set the Permissions parameter to request custom permissions.

To connect to data, set the OAuthAccessToken connection property to the access token returned by the stored procedure. When the access token expires after OAuthExpiresIn seconds, call GetOAuthAccessToken again to obtain a new access token.

Using OAuth on a Headless Machine

To create Reckon Accounts Hosted data sources on headless servers or other machines on which the driver cannot open a browser, you need to authenticate from another machine. Authentication is a two-step process.

  1. Instead of installing the driver on another machine, you can follow the steps below to obtain the OAuthVerifier value. Or, you can install the driver on another machine and transfer the OAuth authentication values, after you authenticate through the usual browser-based flow.
  2. You can then configure the driver to automatically refresh the access token from the headless machine.

You can follow the headless OAuth authentication flow using the driver's embedded OAuth credentials or using the OAuth credentials for your custom OAuth app.

Using the Credentials for a Custom OAuth App

Create a Custom OAuth App

See Creating a Custom OAuth App for information about creating a custom application. After you create your custom app, follow the steps below to authenticate and connect to data.

Obtain a Verifier Code

Set the following properties on the headless machine:

  • InitiateOAuth: Set this to OFF.
  • OAuthClientId: Set this to the App Id in your app settings.
  • OAuthClientSecret: Set this to the App Secret in your app settings.

You can then follow the steps below to authenticate from another machine and obtain the OAuthVerifier connection property.

  1. Call the GetOAuthAuthorizationURL stored procedure with the CallbackURL input parameter set to the exact Redirect URI you specified in your app settings.
  2. Open the returned URL in a browser. Log in and grant permissions to the driver. You are then redirected to the callback URL, which contains the verifier code.
  3. Save the value of the verifier code. You will set this in the OAuthVerifier connection property.

On the headless machine, set the following connection properties to obtain the OAuth authentication values:

  • OAuthClientId: Set this to the consumer key in your app settings.
  • OAuthClientSecret: Set this to the consumer secret in your app settings.
  • OAuthVerifier: Set this to the verifier code.
  • OAuthSettingsLocation: Set this to persist the encrypted OAuth authentication values to the specified file.
  • InitiateOAuth: Set this to REFRESH.

Connect to Data

After the OAuth settings file is generated, set the following properties to connect to data:

  • OAuthSettingsLocation: Set this to the file containing the encrypted OAuth authentication values. Make sure this file gives read and write permissions to the provider to enable the automatic refreshing of the access token.
  • InitiateOAuth: Set this to REFRESH.

Transfer OAuth Settings

Follow the steps below to install the driver on another machine, authenticate, and then transfer the resulting OAuth values.

On a second machine, install the driver and connect with the following properties set:

  • OAuthSettingsLocation: Set this to a writable text file.
  • InitiateOAuth: Set this to GETANDREFRESH.
  • OAuthClientId: Set this to the Client Id in your app settings.
  • OAuthClientSecret: Set this to the Client Secret in your app settings.
  • CallbackURL: Set this to the Callback URL in your app settings.

Test the connection to authenticate. The resulting authentication values are written, encrypted, to the path specified by OAuthSettingsLocation. Once you have successfully tested the connection, copy the OAuth settings file to your headless machine. On the headless machine, set the following connection properties to connect to data:

  • InitiateOAuth: Set this to REFRESH.
  • OAuthSettingsLocation: Set this to the path to your OAuth settings file. Make sure this file gives read and write permissions to the driver to enable the automatic refreshing of the access token.

Copyright (c) 2023 CData Software, Inc. - All rights reserved.
Build 22.0.8462