Note: CData tasks require frends version 5.3 or higher.

CData's online documentation should always be used as a starting point when adopting CData drivers. After selecting a driver, select Online Documentation under ADO.NET Provider. Using Google Drive as an example:

Next, search for documentation on OAuth Authentication, which in the case of Google Drive is under Getting Started → Using OAuth Authentication

There may be several approaches to using OAuth Authention for the driver that you are adopting. Familiarize yourself with the possible options and select one that suits your needs.

Example 1: Google Drive, embedded credentials

In frends, set up a CData Query task with a valid query as seen below.

If you don't have a valid query already, you can find examples in CData's documentation — this query was found under SQL Compliance → Select statements.

Using OAuth authentication will require adding a number of OAuth-related properties to the connection string. The exact properties will depend on the driver and what type of credentials you are using. In this example we will be following the first stage of the instructions for the of using embedded OAuth credentials on a headless machine.

After following the instructions, our connection string could look something like this,

OAuthVerifier=<secret redacted>;InitiateOAuth=REFRESH;OAuthSettingsLocation=C:\Users\Public\Documents\oauth-settings.txt;CallbackURL=urn:ietf:wg:oauth:2.0:oob

after which the task can be run successfully. We had to add the CallbackURL-property, which was not mentioned in that part of the documentation to circumvent an error when running the process. Some resourcefulness on the implementers part may be necessary to supplement CData's documentation.

Example 2: Facebook, custom credentials

Again, we start by navigating to the relevant part of CData's documentation, which directs us to another part of the documentation for creating a custom OAuth application with Facebook as an intermediate step.

Many drivers will require you to register an OAuth application on the target platform to perform OAuth authentication. In our experience, CData's documentation can sometimes be vague or out-of-date but with some resourcefulness these things can be overcome. In particular, you may want to seek out the platform's own documentation and familiarize yourself with the details on how of their OAuth authentication flow works.

Once we have registered a custom OAuth application with Facebook and thereby obtained an OAuthClientId and OAuthClientSecret, we are ready to proceed with authentication using frends.

We have stored the connection string into a trigger variable, and it looks something like this:

OAuthClientId=<App ID>;OAuthClientSecret=<App Secret>

Following OAuth's documentation, we have ended up with a task like this for the first step of the token exchange:

Running this process yields an URL, which we can use to authenticate and be redirected to a callback URL which contains an authorization code.

We can now exchange the authorization code for an access token. Copy the previous task and change Execute to GetOAuthAccessToken and add a new procedure parameter Verifier, containing the value of the code query parameter in the callback URL from before. Running the process and checking the result of the task like last time, we should now obtain an access token.

We add this to our connection string

OAuthClientId=<App ID>;OAuthClientSecret=<App Secret>;OAuthAccessToken=<Access token>

and can now run ExecuteFacebookQuery tasks.


Other example connection strings

Dynamics 365 Sales with Client Credentials

InitiateOAuth=GETANDREFRESH;OrganizationURL=<Url for Dynamics access, e.g. https://xyz.crm4.dynamics.com/api/data/v9.0/>;OAuthGrantType=CLIENT;AzureTenant=<e.g. xyz.com>;OAuthClientSecret=<ClientSecret>;OAuthClientId=<ClientId>;

Dynamics 365 Sales with pre-acquired access token

InitiateOAuth=OFF;OrganizationURL=<Url for Dynamics access, e.g. https://xyz.crm4.dynamics.com/api/data/v9.0/>;OAuthAccessToken=<Access token>;

Did this answer your question?