In this multi-part tutorial, you will discover how to integrate your Salesforce data seamlessly into an OutSystems mobile application. And, you’ll learn to incorporate the Salesforce connector, authenticate with Salesforce, pull data from Salesforce’s servers, and cache the data for use in your mobile application.

This first part of the tutorial covers authenticating with Salesforce on the server side using actions made available through the Salesforce connector. The video included in this tutorial will guide you through the following steps:

  • Integrating the Salesforce connector.
  • Modifying the login screen and process.
  • Authenticating with Salesforce.
  • Caching Salesforce user data to the server.
  • Authenticating the OutSystems user.

Watch the video for the full step-by-step process or read along for an abridged description of the video content.

 

1. Integrating the Salesforce connector

To begin working with your Salesforce data, add the requisite SalesforceREST dependency to your project (Server Actions only). Confirm and wait for Service Studio to finish importing the module.

2. Modifying the login screen and process

Depending on your Salesforce configuration, your users may be required to provide a security token. Alternatively, you can white-list a range of IPs to allow them access by default, but for demonstration purposes, we will use the security token each time we authenticate.

To support this token, modify the Login UI flow to include a third field and label it as the security token field. Create a local variable to store the token for use in the Login action.

3. Authenticating with Salesforce

In the DoLogin user action, add the LoginWithUsernamePassword action provided by the SalesforceREST module. This action requires the username, password, security token, client ID and client secret. Pre-fill the client ID and secret using static properties, and pull the remaining data from the Login action.

4. Caching Salesforce user data to the server

After authentication with Salesforce, use the GetUserDetails action provided by the SalesforceREST module to recover the user’s information. You will cache some of this data to the server to maintain the user’s session and reduce the number of requests you make of the Salesforce API.

Pull the mirrored OutSystems user from an aggregate (filtered by their Salesforce username) and update their information: display name, username, email, and user ID. Perform a CreateOrUpdateUser action to save the data to the server.

5. Authenticating the OutSystems user

Change the User_Login action to a Login action and provide the user’s ID for authentication. By doing so, you avoid storing their Salesforce password on the server and reduce their security risk.

If you have everything set in place, you can safely deploy your changes now and authenticate using your Salesforce credentials. In the next part of our tutorial, we will cache Salesforce user data to the device and present it to the user.