Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 7 Current »

This document provides the details on the steps of how to configure Credit Checker via a custom portal either outside or within Salesforce. We will be covering the below steps in the entire document. Please follow them to get a seamless experience of integrating Credit Checker with your portal.

Set up a Connected App

Once you have your developer account set up you’ll want to set up a Connected App.

For the purposes of this and how we’re going to use it, it’s easiest to think of a connected app as a small app that sits on Salesforce’s infrastructure that you point your integration to. It is responsible for managing the authentication and also routing of requests to the relevant client instances.

Once you’ve set up your Salesforce developer account, you can set up a connected app by clicking the Setup icon in the top-right navigation menu and select Setup.

Enter App Manager in the Quick Find box and then select App Manager.

  1. Click 

New Connected App.

  1. In the New Connected App form, fill in:

In the Basic Information section:

  1. Connect App Name: YourAppName.

  2. API Name: this will automatically become ‘YourAppName’.

  3. Contact Email: enter your email address.

In the API (Enable OAuth Settings) section:

  1. Check Enable OAuth Settings.

  2. Callback URL: enter your Callback URL, example: https://www.yourappname.com/api/callback

This will be the URL that Salesforce POSTs to when the user has authorized your app to access their data. This will include the access and request token (we’ll explain a bit more on this below but they are essential to be able to send and receive data.) So if you don’t have one already, you’ll need to set up an endpoint whose role it is to receive and handle this request.

Under Selected OAuth Scopes:

  1. Select Access and manage your data (API).

  2. Click Add.

Once you’ve set up your app, you’ll be given a Consumer Key and a Consumer Secret for your app.

To start, your user is directed to a Saleforce.com authorization endpoint, where they log in and approve access for your app to access their data.

After successful authorization, Salesforce sends a response with an Access token and Refresh token.

The Access token is to be passed in the header of all API requests for data. This token has an expiry date and will always expire. By default, the Connected Apps have an access token with an expiry of 15 minutes (in line with the sessions settings within your Salesforce settings).

The Refresh token is to be used to retrieve a valid access token (e.g. when the current access token expires). You can change the expiry settings on this but you can also set this never to expire, only when it is revoked.

Example API calls:

To make the initial authorization request for a user to grant your app access to their data (this is where your user is initially directed to a Saleforce.com authorization endpoint and logs in) you’d make the following request. The ClientID in the below call will be your consumer ID from the connected app. The redirect_url will be the Callback URL.

 
curl https://login.salesforce.com/services/oauth2/authorize?response_type=code
&client_id=YOURCONSUMERID&redirect_uri=https://www.yourappname.com/api/callback
 
 

A successful response from this will redirect the page to a Salesforce login page where the user is able to log in and authenticate. After Salesforce confirms that the client has authorized your app to access their data, the end user's browser is redirected to the callback URL you’ve specified by the redirect_uri parameter. Salesforce then appends an authorization code to the redirect URL, their request will look similar to the below.

You’ll use this as the value for your code parameter when you make a request to Salesforce’s token endpoint to receive your Access and Refresh Token.

Example request:

curl login.salesforce.com/services/oauth2/token?grant_type=authorization_code&redirect_uri=https://www.yourappname.com/api/callback&client_id=YOUR_CONSUMER_ID&client_secret=YOUR_CONSUMER_SECRET&code=aWekysIEeqM9PiThEfm0Cnr6MoLIfwWyRJcqOqHdF8f9INokharAS09ia7UNP

Example Response:

 
{
  "access_token": "YOUR_ACCESS_TOKEN",
  "refresh_token": "YOUR_REFRESH_TOKEN",
  "signature": "signature",
  "scope": "refresh_token api id",
  "instance_url": "https://instance.salesforce.com",
  "id": "https://login.salesforce.com/id/id,
  "token_type": "Bearer",
  "issued_at": "timestamp"
}

Outside of the access and response token, the instance URL is imported also. It’s what you’ll need to build the base of your future API calls.

Now we have the access token, we’re able to start making requests to send and receive data on our user's behalf. Something to keep in mind though, as mentioned earlier, is that these access tokens will always expire at some point.

Due to that, you’ll want to keep your access token up to date by making a call to the token endpoint and changing the grant_type to ‘refresh_token’ along with including the refresh token you had received in the previous call.

Example call:

curl https://login.salesforce.com/services/oauth2/token?=YOUR_REFRESH_TOKENgrant_type=refresh_token&client_id=YOUR_CONSUMER__ID&client_secret=YOUR_CONSUMER__SECRET&refresh_token

Example response:

curl
{
  "access_token": "REFRESHED_ACCESS_TOKEN",
  "signature": "signature",
  "scope": "refresh_token id api",
  "instance_url": "https://INSTANCE.salesforce.com",
  "id": "https://login.salesforce.com/id/idE",
  "token_type": "Bearer",
  "issued_at": "timestamp"
}

Now we have a way to keep our access tokens valid and up to date, we’re set up and ready to start working with Salesforce objects.

Send data from your app to Salesforce

Creating a contact in salesforce is really straightforward. You just need to build the API URL using the instance from your access token response and use the access token value as your bearer token in the header.

One thing to keep an eye out for through is for characters that need to be escaped in your access token.

For example, this access token should have the exclamation mark escaped

So this:

00D1r000000dumU!AQEAQFd.O1Q5DVQrUYvr.........

Becomes this:

 
00D1r000000dumU\!AQEAQFd.O1Q5DVQrUYvr........

you can then make the below call to create a Credit Report.

Example request

 
curl https://INSTANCE.salesforce.com/services/data/v42.0/sobjects/ creditchecker_Credit_Report__c -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"creditchecker__Applicants_First_Name__c" : "Johnny", 
" creditchecker__Applicants_Last_Name__c " : "Appleseed",
“creditchecker__Current_Line__c “:”220 Locust Ave”,
“creditchecker__Current_StateCode__c”:”MO”,
“creditchecker__Current_City__c “:”Anthill”,
“creditchecker__Current_Zip_Code__c “:”65488”,
“creditchecker__SSN__c “:”000000001”,
“creditchecker__Current_Country__c “:”United States”}'
 

(Your Credit Report will need these fields as the minimum for an entry to be created.)

Fields:

Name

Value

creditchecker__Applicants_First_Name__c

Borrower’s First Name

creditchecker__Applicants_Last_Name__c

Borrower’s Last Name

creditchecker__Applicants_SSN__c

Borrower’s SSN

creditchecker__Current_Line__c

Borrower’s Street Address

creditchecker__Current_StateCode__c

Borrower’s State Code

creditchecker__Current_City__c

Borrower’s City

creditchecker__Current_Zip_Code__c

Borrower’s ZIP Code

creditchecker__Current_Country__c

Borrower’s Country

 

The response you get back will be the id of your Credit Report

{"id":"0031r000029NDckAAG","success":true,"errors":[]}

Which will also let you build a link directly to the Credit Report.

 https://INSTANCE.salesforce.com/0031r000029NDckAAG

 

In case of any questions or concerns please feel free to reach out to us at support@cloudmaveninc.com

  • No labels