The steps to building a Community Connector are:
- Create a new Apps Script project.
- Write the connector code.
- Complete the project manifest.
Create a new Apps Script project
Visit Google Apps Script to create a new project. Apps Script will create a
default script for you. Feel free to remove the myFunction
function and rename
the project. (Learn more about Apps Script)
Write the connector code
Every connector is required to have a specific set of functions defined. The hosting application (e.g. Looker Studio) will execute these functions. Your connector is expected to handle incoming requests and respond as described in the Community Connector API reference. If you face issues while developing your code, read the debugging guide for help.
Define authentication type in getAuthType()
This function is called to identify the authentication method used for the
3rd-party service. See the getAuthType() reference for details. Currently
supported authentication methods are listed in AuthType
reference.
For example, the following connector does not require authentication:
If your data source requires OAuth 2.0 authentication, view the OAuth 2.0 authentication guide and add the additional required functions to your connector.
Define configuration via getConfig()
The getConfig()
function is called to get the configuration for the
connector, including the user provided values that your connector requires. See
getConfig()
reference for details.
Based on the response provided by getConfig()
, Looker Studio will render the
connector configuration screen. The configuration elements supported are listed
in ConfigType
reference.
If your data source requires date as a parameter, call config.setDateRangeRequired(true). If you need to ask conditional or dynamic configuration questions, see stepped config.
The following is an example of a connector that requires the user to enter an
npm package name code. An info and an input field are defined in the
getConfig()
function:
Define the fields with getSchema()
This function is called to get the schema for the given request. Any
configuration parameters defined by the getConfig()
function will be provided
in the request
argument. See getSchema()
reference for details.
Depending on your connector's data source and the configuration provided by the user, the schema may be fixed or you may have to dynamically provide this at request time.
For example, if a connector is fetching report data based on a Report ID, the
data returned for that report and hence the schema may not be known beforehand.
In this case getSchema()
may require a data fetch and the schema will have to
be calculated.
Fetch and return data with getData()
This function is called to get data for the given request. Any configuration
parameters defined by the getConfig()
function will be provided in the
request
argument. See getData()
reference for details.
The following parameters from the getData()
request require additional
attention:
lastRefresh
lastRefresh
represents a timestamp that marks the time of the most recent request for a refresh of data. You should be able to parse the value withnew Date(timestampString)
. If you are using Apps Script Cache Service or any other caching method, thelastRefresh
timestamp can help you to determine whether to make a new fetch request to the data source or serve data from the cache.dateRange
IfdateRangeRequired
is set totrue
ingetConfig()
, eachgetData()
call will contain the selected date range in the request. See Working with Date Ranges for more details.
The following example fetches data based on the incoming request and returns the package statistics:
Complete the project manifest
The manifest file contains information about your Community Connector that is required to deploy and use your connector in Looker Studio.
To edit the manifest file in the Apps Script development environment, click on
the View menu and click Show manifest file. This will create a new
appsscript.json
manifest file.
Update the manifest to include the following data:
For details on Looker Studio manifest, see the reference manifest reference.
Next steps
The next step will be to deploy your Community Connector.