Google Spreadsheet Data Sources

The Google JCA connector is named teiid-connector-google.rar. The examples include a sample google.xml file. The JCA connector has number of config-properties to drive authentication.  The JCA connector connects to exactly one spreadsheet with each sheet exposed as a table.

Authentication to your google account may be done using OAuth, which requires a refresh token (outlined below).

Config property Description

ClientId

client ID for access. If not specified, the Teiid default will be used.

ClientSecret

client secret for access. If not specified, the Teiid default will be used.

RefreshToken

Use guide below to retrieve RefreshToken. Request access to Google Drive and Spreadsheet API.

SpreadsheetName

Required property with name of the Spreadsheet that is datasource for this connector. By default it is assumed to be a title.

Key

Optional boolean property to designate the spreadsheet name is a key rather than a title.

BatchSize

Maximum number of rows that can be fetched at a time. Defaults to 4096.

Create Authorization Credentials

It is recommended that you create your own authorization credentials rather than relying on the default Teiid client id and client secret. Creating your own project will give you greater control over monitoring and controlling API access.

You should follow the OAuth2 For Devices Guide prerequisites. You should allow the project access to Google Drive API and the Sheets API.

A condensed form of the rest of the guide "Obtaining OAuth 2.0 access tokens" is covered next as "Getting an OAuth Refresh Token".

Getting an OAuth Refresh Token

With a browser or other client issue the request with the appropriate client ID:

Then copy the authorization code into following POST request and run it in command line:

curl \--data-urlencode code=<AUTHORIZATION_CODE> \
--data-urlencode client_id=<CLIENT_ID> \
--data-urlencode client_secret=<CLIENT_SECRET> \
--data-urlencode redirect_uri=urn:ietf:wg:oauth:2.0:oob \
--data-urlencode grant_type=authorization_code https://accounts.google.com/o/oauth2/token

The refresh token will be in the response.

To use the Teiid defaults:

Then copy the authorization code into following POST request and run it in command line:

curl \--data-urlencode code=<AUTHORIZATION_CODE> \
--data-urlencode client_id=217138521084.apps.googleusercontent.com \
--data-urlencode client_secret=gXQ6-lOkEjE1lVcz7giB4Poy \
--data-urlencode redirect_uri=urn:ietf:wg:oauth:2.0:oob \
--data-urlencode grant_type=authorization_code https://accounts.google.com/o/oauth2/token

Implementation Details

Google Translator is implemented using GData API [1] (java library for [4]) and Google Visualization Protocol [2]. Authentication is implemented using OAuth2 for devices [3]. 1. https://developers.google.com/google-apps/spreadsheets/ 2. https://developers.google.com/chart/interactive/docs/querylanguage 3. https://developers.google.com/accounts/docs/OAuth2ForDevices 4. https://developers.google.com/google-apps/spreadsheets

results matching ""

    No results matching ""