Implementing OAuth 2.0 With Client Credentials
In this blog, let us discuss about how to do a Manual OAuth call with client credentials grant type.
- To do manual OAuth call in boomi, we have a connector called “HTTP Client” through which we can use the service provided by third party API.
- Here, we want to access particular employee data from salesforce API where we give id as an input and will fetch complete data of an employee as the response.
Now, let us see the steps of “how to do the manual OAuth call”.
Step 1: Firstly, create a process with a start shape and type http in search map, you will get to see “Http Client” connector.
Step 2: Drag and drop “Http Client” connector onto the process canvas.
Step 3: Now, we have to configure 3 things in the connector i.e Action, Connector and Operation.
Step 4: If we look at the Action, we find two operations i.e Get and Send. If we are sending data to an API, we will use send operation.
Step 5: To configure the connection, Click + and give a relevant name to the connection. You see 2 parts in the connection tab i.e URL and Authentication type.
- In place of URL, give base url of an api for which you want to consume the service.
- Here we will call the salesforce URL configured in the salesforce connected app in order to get the access token.
- We need to configure the connected app callback URL as base url, in this secanrio which is “https://techygeekhub7-dev-ed.develop.my.salesforce.com/”
- Based on the authentication type provided by the third party api, we have to choose the field. We are going to leave it as none which is default (as we don’t have any authentication)
- Click on save and close.
Step 6: Now, click on + to configure the operation and give a relevant name.
In options tab, we find connector action as GET by default ,we have to configure SEND in the connector.
- Select request and response profiles based on the data that is being sent and received by the connector. we will put both request and response profiles as NONE as we don’t need any request or response profiles to access the API as we would only want records to be retrieved.
- Content type describes the format of how data is represented. In this example, it is application/x-www-form-urlencoded.
- HTTP Method defines the type of request. In this case, it would be SEND as we are sending some required data to get back the token from token server.
Step 7:
- If you scroll down you will find Request Headers where you can add the headers which are required to access the API. In this case, we don’t have any headers.
- Next, place the resource path i.e (add the path which is after the base path).
- For suppose, the URL which we are going to access is “https://techygeekhub7-dev-ed.develop.my.salesforce.com/”. So, “https://techygeekhub7-dev-ed.develop.my.salesforce.com/” becomes the base path, and “services/oauth2/token” will be added to the resource path.
- By calling this endpoint we will get back the access token.
Click save and close
Step 8: We need to drag and drop a message shape to pass the required information to the HTTP Client Connector.
- In the message shape we will pass grant_type=client_credentials&client_id=
{1}& client_secret={2}.
- The 1st place holder {1} will carry the value of client id and the 2nd place holder {2} will carry the value of the client secret which we can find from the salesforce connected app.
Step 9: Now we need to drag and drop a set properties shape. Then we need to setup a Dynamic Process Property to capture the Access Token.
Step 10: Now we need to drag and drop a branch shape and we connect the first branch to the above built logic and in the second branch we will built the logic to use the retrieved token and get the resource.
Step 11: Drag and drop a HTTP Connector and configure it with the Base URL as “https://techygeekhub7-dev-ed.develop.my.salesforce.com/”.
Step 12: Now we need to configure the action as Get and we need to configure the operation in HTTP connector.
Step 13: We need to configure the Request and Response profile. We will select as None.
- Then we need to configure the request header as we have to pass the access token in the header.
- To do so, we need to click on the plus icon and we need to add one header named “Authorization”. The value section we choose as a replacement variable as we will pass it from parameters.
- Then we will configure the resource path as “services/data/v57.0/sobjects/Account/0015i00000oTv9YAAS” to get back the resource.
Step 14: To pass the token value we need to drag and drop a set properties before the HTTP connector.
- On the set properties we need to configure a Dynamic Document Property same as the replacement variable name of the request header name of the HTTP connector operation.
- We need to pass the Dynamic process property value configured before which we used to capture the token.
Step 15: We need to drag and drop a STOP shape to stop the flow of execution.
After configuring everything our process will look something like shown in the below.
Step 16: Now we need to test the process and we can get the resource from the salesforce as shown below.