Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This tutorial will guide you on how to expose data in a google spreadsheet as a data service.

...

...

  1. Click Add New Datasource to open the following screen.
  2. Follow the instructions below to fill the datasource details.

    1. In the Datasource Id field, enter GoogleSpreadsheet as the value.

    2. In the Datasource Type field, specify the type of datasource for which the data service is created. Select Google Spreadsheet from the list. You will now get the following screen:

    3. In the Google Spreadsheet URL field, specify the path to your spreadsheet. The file we are using for this tutorial is https://spreadsheetsdocs.google.com/ccc?key=0Av5bU8aVtFjPdElrUVN3VmZlRkoyM1ZzVlE1MzdtbXc/spreadsheets/d/1o1pCmMFcbWZ_eJ54ymcb486GctTdsR6b4kFERmKrR1w/edit?hl=en&hl=enen#gid=0.

      Note

      Note that this is a private spreadsheet, which is not published on the web. If you want to use a public spreadsheet, see the topic on exposing a public spreadsheet as a data service.

    4. Anchor
      visibility
      visibility
      Select a value for the Visibility field based on whether the spreadsheet is private or public. Since we have used a private spreadsheet in this example, set the visibility to PrivateYou are asked to provide credentials as well as a browser redirect URL that is known to your browser. Google no longer supports authentication through username and password. Therefore, it is now necessary to provide credentials in the form of a Client IDClient Secret and Refresh Token.

    5. See 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 the same URL as the browser redirect URL shown above.

      Info
      titleSetting the hostname

      Note that the Redirect URI should contain the same host name as the Authorized Redirect URl that you provided in the previous step, as well as the host on which the management console runs.

      • If the server is running on your machine, you can simply use "localhost" as the hostname (or the direct IP address, which is 127.0.0.1). 

      • If the server is running on a local network, you must always use a host name instead of the direct IP address. This is because publicly shared IPs cannot be used. You also need to ensure that the hostname you use is known to the browser by registering it in your "/etc/hosts" file.

    6. Update the Client ID and the Client Secret fields in the Edit Datasource screen with the values you got in the previous step.

    7. Click Generate Token. You will now be redirected to the google consent page. After you approve that, the refresh token will be inserted into the New Datasource screen automatically. Note that we just store the refresh token because the access token is going to expire anyway.

    8. Anchor
      use_query_mode
      use_query_mode
      The Use Query Mode option allows you to write queries for the spreadsheet in two different modes:

      • Non-Query mode: Allows you to directly expose the contents of a Google spreadsheet as a service.

      • Query mode: Allows you to query a Google spreadsheet in a familiar, SQL-like manner, and expose the result as a service. You need to provide the name of the spreadsheet, in addition to the spreadsheet URL.

      See the next section on defining queries for more information on how the query mode affects how you query data in the spreadsheet.

  3. Save the datasource.
  4. Click Next to go to the Queries screen

...