Skip to main content
This page contains code examples for the Custom Connector sections that require JavaScript. The Connector Dev Studio has several built-in functions to make the process easier for you. For a list of these built-in JavaScript functions, see Reference.

User Authentication


No Authentication

No code is required. But if you would like, you can make an API call to check the connection.

Username and Password

Determine how your API endpoint needs to authenticate with the username and password. Most endpoints that use username and password will use the Basic Authentication standard. The username and password are stored in the metadata.account object. Access the stored username and password
Basic authentication with 64-bit encoding

API Key

An API key is a token passed in as a header or a query parameter in an HTTP request. It uniquely identifies who is making the call and is often non-expiring. You will need to determine how the REST API you wish to call needs to send the API key. The API key is stored in the metadata.account object. If your API endpoint requires it, the Connector Dev Studio includes functions for building a JSON Web Token (JWT). Access the stored API key
Use the API key as a query parameter
Insert the API key into the header
Build a JWT token

OAuth 2.0

OAuth 2.0 is the industry-standard for secure authentication. If your cloud API endpoint uses OAuth 2.0, you are in luck: Domo has automated the processes of using your stored data to retrieve your access token. After you have filled in the appropriate fields and clicked Get Access Token, your access token and code are stored in the metadata.account object. Access the stored access token and code
Set authentication success based on token
Set authentication success based on call made with token
This example makes a call to the Facebook API to get all the pages controlled by this user. It inserts them as options into a discovery dropdown. This will allow a user to select just one Facebook page to run a report on. Dropdown methods
Access dropdown parameter data
Dropdown discovery example

Basic Tree Menu

This example makes a call to the Facebook API to get all the pages controlled by this user. This will allow the user to select multiple Facebook pages to run a report on. To create a series of checkboxes, add each item as a leaf to the root node, discovery.tree. The results selected by the users are stored in a JavaScript array. Access tree menu root node
Tree menu methods
Access tree menu parameter data
Basic tree menu discovery example

Nested Tree Menu

You can nest checkboxes into categories by adding nodes to the discovery.tree root. If a user checks a parent checkbox, all the checkboxes nested in it will be selected. This example nests countries in parent nodes that represent regions. The results selected by the users are stored in a JavaScript array. Access tree menu root node
Tree menu methods
Access tree menu parameter data
Nested tree menu discovery example

Process Data Examples


The Connector Dev Studio has a couple of example connectors provided to you: Sample CRM and USGS. The following examples of data processing blocks are pulled from these sample connectors.
Sample Custom Connector

Sample CRM

  • Authentication type: Username and password
  • Reports: Opportunities
  • Parameters: None
  • Endpoint data return format: CSV

Sample CRM using datagrid.magicParseCSV

  • Authentication type: Username and password
  • Reports: Opportunities
  • Parameters: None
  • Endpoint data return format: CSV

USGS

  • Authentication type: None
  • Reports: Past Hour, Past Day, Past 7 Days, Past 30 Days, Pull data from the last X day(s)
  • Parameters: None
  • Endpoint data return format: JSON