Scenario: Using OAuth2 to log in to Salesforce.com - 6.3

Talend Open Studio for Big Data Components Reference Guide

EnrichVersion
6.3
EnrichProdName
Talend Open Studio for Big Data
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

In this scenario, the OAuth2 (Open Authorization 2.0) method is adopted to authorize tSalesforceConnection to access the Salesforce.com resources. This way, better security is achieved as users do not need entering their Salesforce username/password directly on tSalesforceConnection, which is required by the Basic login type instead.

Setting up the Job

  1. Drop a tSalesforceConnection component, a tFixedFlowInput component and a tSalesforceOutput component onto the workspace.

  2. Link the tFixedFlowInput component to the tSalesforceOutput component using a Row > Main connection.

  3. Link the tSalesforceConnection component to the tFixedFlowInput component using a Trigger > OnSubjobOk connection.

Configuring the components

  1. Double-click the tSalesforceConnection component to open its Basic settings view.

  2. In the Connection type list, select OAuth.

    In the Client Id and Client Secret fields, enter the key and secret used by the consumer to access Salesforce respectively.

    In the Callback Host and Callback Port fields, enter the callback host and port information respectively.

    In the Token File field, browse to or enter the path to the token file that stores the refresh token used by the OAuth-enabled connected app to obtain new sessions without requiring the user to provide their credentials.

  3. Double-click the tFixedFlowInput component to open its Basic settings view.

  4. Click the [...] button next to Edit schema and in the pop-up schema dialog box, define the schema by adding one column Name of String type.

    Click OK to save the changes and close the dialog box.

  5. In the Mode area, select Use Inline Content (delimited file). Then in the Content field displayed, enter the data to be written into Salesforce. For example,

    Talend
  6. Double-click the tSalesforceOutput component to open its Basic settings view.

  7. In the drop-down list next to the Property Type drop-down list, select the tSalesforceConnection component to reuse the connection created by it.

  8. Click the [...] button next to the Module Name field and in the pop-up dialog box, select the object you want to access. In this example, it is Account.

  9. Click the [...] button next to Edit schema to open the schema dialog box.

    On the right side of the panel, remove all the columns except the Name column.

    Click OK to save the changes and close the dialog box.

Executing the Job

  1. Press Ctrl + S to save the Job.

  2. Press F6 to run the Job. The Studio console gives the URL (in yellow) for OAuth authorization.

  3. Copy the URL to the browser's address bar. The Salesforce.com login page appears.

  4. Fill up the username and password and click Log in to Salesforce.

    The authorization response is then shown on the browser at the callback host.