Create an Authenticated Server-to-Server Connection
To set up a server-to-server web connection, you need to create a connected app, add the connector in Data Cloud, and create a data stream for the data. Use a server-to-server connector when your server already collects engagement data that you want to forward to Data Cloud or when you require an authenticated connection to Data Cloud.
To configure OAuth for the connected app you will use in your server-to-server connection, create a private/public RSA key pair and a digital x509 certificate.
Important: If you already have a connected app that you want to use, ensure that you have the private/public RSA key pair you used to create the x509 certificate for that app, as you need them to enable OAuth in a subsequent step.
- From your terminal, change directories to any folder.
- Create the private/public key pair.
- Create a digital certificate from the key pair.
- Complete the questions as prompted.
- Create a pkcs8 private key from the key pair.
- Keep the private/public key pair and the digital x509 certificate, as you need them in the following task.
You must configure a connected app to send data into Data Cloud using a server-to-server connection.
- In the Setup’s Quick Find, search for "App Manager".
- Select New Connected App and set the required connection values.
- Select Enable OAuth settings.
- To use JWT OAuth Flow, select Use Digital Signatures.
- Enter the callback URL (endpoint) that Salesforce calls back to your application during OAuth. It’s the same as the OAuth redirect URI.
- Click Choose File, and select the certificate (.crt file) you created in Create a Private/Public Key Pair and Certificate.
- Set these OAuth scopes:
- Manage user data via APIs (api)
- Perform requests at any time (refresh_token, offline_access)
- Manage Data Cloud Ingestion API data (cdp_ingest_api)
- Clear the selection for Require Proof Key for Code Exchange (PKCE) Extension for Supported Authorization Flows.
- Note the Consumer Key and Callback URL.
- Select Edit Policies.
- Change IP Relaxation to Relax IP restrictions.
- Change Permitted Users policies to All users may self-authorize.
- Click Save.
Using the Consumer Key and Callback URL created in Enable OAuth settings for the API integration, paste the following URL into your browser using the noted values:
You can create a secure server-to-server connection between your website source and Data Cloud to programmatically capture and ingest data.
-
In Salesforce, go to Setup, and then select Data Cloud Setup.
-
Click Web & Mobile SDK, and then click New.
-
Enter the app name, and for connector type, select Server to Server. If needed, you can later edit the app name.
-
To select a JSON Event Type schema file from your computer, in the Schema section, click Upload Files.
-
Preview the schema and verify your Event Category, Field data types, Primary Key, and whether a field is marked as required.
-
Confirm that all events and fields are populated accordingly and save your work.
-
After your schema is uploaded, compare it with your JSON schema file for accuracy.
- To change your schema at any point, click Update Schema. You can only add events or fields; the schema must retain all previous events and fields
- To update your schema, click Yes, Update or to view the full schema you uploaded, click View Full Schema.
-
In the integration section, copy the system-generated Source ID. You need this to make server-to-server requests as the
{appSourceId}
.
Create a data stream to begin the flow of engagement and profile data in real time from your server to Data Cloud. Data streams refresh engagement data every 15 minutes and profile data every hour from the data stream.
-
In Data Cloud, navigate to the Data Streams tab.
-
Click New.
-
Select Server to Server.
If you don’t see the data source that you want, confirm whether your Data Cloud administrator uploaded the JSON schema for that application.
-
Click Next.
-
Select the events to include in the data stream and click Next. The events are pulled from the JSON schema uploaded in Setup.
-
Review the list of selected events, their associated fields, and how the data source objects are mapped to the data model objects.
-
Click Next.
A separate data stream is created for each event with category = "Profile". A single data stream is created for all events with category = "Engagement".
-
If you have more than one data space, select the data space for this data stream using the Data Space dropdown menu.
-
To create the data stream, click Deploy.