Google Spreadsheet Sample
Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:<PRODUCT_HOME>/
repository/samples/
directory that includes all Data Integration samples is changed to <EI_HOME>/
samples/data-services/
.<PRODUCT_HOME>/
repository/samples/resources/
directory that includes all artifacts related to the Data Integration samples is changed to <EI_HOME>/
samples/data-services/resources/
.
A data sharing format used often in the Internet is Google Spreadsheet. WSO2 Enterprise Integrator (WSO2 EI) contains support for Google Spreadsheets as a data source.
About the sample
The spreadsheet contains data about the customers of a specific company. The GSpread sample service contains a single operation named getCustomers , which returns all the customer information that is stored in the Google spreadsheet. There is also a resource defined as customers, which can be accessed using the following URL: "http://localhost:9763/services/GSpreadSample.HTTPEndpoint/customers".
See Data integration for a definition of data services and operations.
Building the sample
The sample data service named GSpreadSample should be deployed and configured as follows:
- Follow the instructions in Samples Setup to have the sample deployed.
Because we are using a Google spreadsheet as the datasource, we need to update the credentials for accessing the spreadsheet. This is done using a Client ID, Client Secret and Refresh Token that is generated from the Google API Console. Follow the google documentation for instructions on how to get an OAuth2 client ID and client secret. In order to get these credentials, you will be asked to provide an authorization redirect URL. Be sure to use localhost as the IP in the browser redirect URL.
- Now you can add the credentials to the GSpreadSample data service as follows:
Log in to the management console of your server using the following URL: https://localhost:8243/carbon/
For the purpose of this sample, be sure to use localhost as the IP in the above URL.
- Click List under Services in the navigator. The GSpreadSample will be listed there.
- Click the GSpreadSample to open the sample's dashboard.
- Click Edit Data Service Wizard to start editing the data service using the management console.
- Click Next until you reach the Datasource screen shown below.
- Click the GSpreadSample datasource to start editing the datasource.
- Note that a client ID, client secret and refresh token are specified by default. Replace the Client ID and Client Secret values using the new values you obtained in step 2 above.
- Click Generate Token. You will be redirected to the google consent page. After you approve that, the refresh token will be inserted into the Refresh Token field as shown below.
- Save the datasource. You can now run the sample as explained below.
Running the sample
The sample service can be run using the TryIt tool, which is bundled with the WSO2 Data Services Server, or a code-generated java client sample as discussed in the Data Services Clients section.
Follow the steps below to demonstrate this functionality using the TryIt tool:
- In the management console of your server and click List under Services in the navigator. The GSpreadSample will be listed here.
- Click Try this service to open the TryIt tool.
- Select the "getCustomers" operation and click Send to execute the request. You will get the customer details in the response as shown below.