IDM 7.4.1

Synchronize data between IDM and HubSpot

This sample demonstrates bidirectional synchronization between IDM managed users and HubSpot contacts.

Prepare the sample

The sample assumes that you have a client app in HubSpot, with the corresponding clientID, clientSecret, and refreshToken, and that you already have some contacts stored in HubSpot.

Get the refresh token

  1. Browse to the following URL:

    https://app.hubspot.com/oauth/authorize?client_id=clientID&scope=contacts&redirect_uri=your-domain
  2. On the resulting page, select your user account in HubSpot. You are redirected to a URL similar to the following:

    https://your-domain/?code=860c1867-9e4b-4761-82c4-1a5a4caf5224
  3. Copy the code in this URL (860c1867-9e4b-4761-82c4-1a5a4caf5224 from the above example). You will need the code for the following step.

  4. Send the following POST request, substituting your clientID and clientSecret:

    curl \
    --request POST \
    --header 'Cache-Control: no-cache' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'grant_type=authorization_code&client_id=your-id&client_secret=your-secret&redirect_uri=your-domain&code=code' \
     "https://api.hubapi.com/oauth/v1/token"
    {
      "refresh_token": "f37e1132-xxxx-xxxx-xxxx-xxxx",
      "access_token": "CKbm...VaE",
      "expires_in": 21600
    }
    The redirect_uri must be URL-encoded in this request, for example, redirect_uri=https%3A%2F%2Fwww.example.com%2F.

    The output of the POST request includes the refresh_token required to configure the connector.

Run the sample

In this section, you will do the following:

  1. Download and install the HubSpot connector.

  2. Start IDM with the sample configuration.

  3. Configure the HubSpot connector and test your connection to HubSpot.

  4. Reconcile your HubSpot contacts with the IDM managed user repository.

  5. Change a user in IDM and reconcile the changes back to HubSpot.

The mapping configuration file (sync.json) for this sample includes two mappings: systemHubspotContact_managedUser and managedUser_systemHubspotContact. You will use these mappings to reconcile users between IDM and HubSpot.

  1. To install the HubSpot connector, download the connector jar from the ForgeRock BackStage download site site and place it in the /path/to/openidm/connectors directory:

    mv ~/Downloads/hubspot-connector-1.5.2.0.jar /path/to/openidm/connectors/
  2. Start IDM with the configuration for the HubSpot sample:

    cd /path/to/openidm/
    ./startup.sh -p samples/sync-with-hubspot
  3. To configure the HubSpot connector, do one of the following:

    • Update samples/sync-with-hubspot/conf/provisioner.openicf-hubspot.json with your HubSpot clientID, clientSecret, and refreshToken, and setting "enabled" : true.

    • Use the admin UI to configure the connector.

      1. Select Configure > Connectors, and select the HubSpot connector.

      2. Complete at least the Base Connector Details and enable the connector.

  4. Test the connection to HubSpot by running the following command:

    curl \
    --header "X-OpenIDM-Username: openidm-admin" \
    --header "X-OpenIDM-Password: openidm-admin" \
    --header "Accept-API-Version: resource=1.0" \
    --request POST \
    "http://localhost:8080/openidm/system?_action=test"
    [
      {
        "name": "hubspot",
        "enabled": true,
        "config": "config/provisioner.openicf/hubspot",
        "connectorRef": {
          "bundleVersion": "[1.5.0.0,1.6.0.0)",
          "bundleName": "org.forgerock.openicf.connectors.hubspot-connector",
          "connectorName": "org.forgerock.openicf.connectors.hubspot.HubspotConnector"
        },
        "displayName": "Hubspot Connector",
        "objectTypes": [
          "company",
          "contactProperties",
          "__ALL__",
          "companyProperties",
          "contact"
        ],
        "ok": true
      }
    ]

    A status of "ok": true indicates that the connector can connect to HubSpot.

    If you configured the connector through the admin UI, the connection is tested as soon as you select Save.
  5. To reconcile your HubSpot contacts with the IDM managed user repository, do one of the following:

    • Run the command:

      curl \
      --header "X-OpenIDM-Username: openidm-admin" \
      --header "X-OpenIDM-Password: openidm-admin" \
      --header "Accept-API-Version: resource=1.0" \
      --request POST \
      "http://localhost:8080/openidm/recon?_action=recon&mapping=systemHubspotContact_managedUser&waitForCompletion=true"
      {
        "_id": "1f148024-45b9-4dc1-9c3f-29976e02db00-3768",
        "state": "SUCCESS"
      }
    • In the admin UI, select Configure > Mappings, and then select Reconcile on the systemHubspotContact_managedUser mapping.

  6. In the admin UI, select Manage > User, and verify that your HubSpot contacts have been created as IDM managed users.

  7. In the admin UI, select Manage > User, select a user to edit, and change one of the user properties.

  8. To reconcile the managed user repository with your HubSpot contacts, do one of the following:

    • Run the command:

      curl \
      --header "X-OpenIDM-Username: openidm-admin" \
      --header "X-OpenIDM-Password: openidm-admin" \
      --header "Accept-API-Version: resource=1.0" \
      --request POST \
      "http://localhost:8080/openidm/recon?_action=recon&mapping=managedUser_systemHubspotContact&waitForCompletion=true"
      {
        "_id": "1f148024-45b9-4dc1-9c3f-29976e02db00-8700",
        "state": "SUCCESS"
      }
    • In the admin UI, select Configure > Mappings, and then select Reconcile on the managedUser_systemHubspotContact mapping.

  9. In HubSpot, verify that the contact was updated.

For more information about the HubSpot connector, refer to HubSpot connector.

Copyright © 2010-2024 ForgeRock, all rights reserved.