Salesforce OAuth Configuration in webMethods.io Integration and webMethods.io Flow Editor

Summary:

    This article describes the successive way to construct an OAuth app in Salesforce, token generation and configuring an account in both webMethods.io flow editor and webMethods.io Integration.

Prerequisites:

  • ·  User must have a developer account created in Salesforce.com
  •    Working webMethods.io flow editor tenant.
  •    Working webMethods.io integration tenant.

Contents:

1. Create a Connected App in Salesforce

2. Generate an Access Token and Refresh Token using REST client

3. Configuring a Salesforce Account in webMethods.io flow editor.

4. Configuring a Salesforce Account in webMethods.io integration.

Steps:

 1. Login to Salesforce https://login.salesforce.com

 2. In upper-right corner click on “Setup

 3.  In the left-hand pane, find Apps in quick find box (Build > Create >Apps)

 4.  In the Connected Apps pane, click on New field

                

 

 5. Fill out the Basic information like "Connected App Name", "API Name" , "Contact Email" and select Enable OAuth Settings under API (Enable OAuth Settings) field

 6. In the Callback URL field, enter the callback URL

     Ex: https://www.softwareag.com

 

 7. In the Selected OAuth Scopes field, add all “Available OAuth Scopes

                                                

 8. Click the Save button to save the new Connected App and “continue” to take effect on the server.

 Note: Allow from 2-10 minutes for your changes to take effect on the server before using the connected app.

 9. In the Connected Apps list, find the App that you just created, and then click Manage under API (Enable OAuth Settings) note down 

 Consumer Key (client id) and click on  “click to reveal” to view Consumer Secret (client secret)

 

 10. To generate authorization code: Go to Chrome browser and input the below url

  https://<instance_name>.salesforce.com/services/oauth2/authorize?response_type=code&

  client_id={consumer_key}&redirect_uri={callback_url}

    Note: find your instance name from the login url. Ex: instance name here is ap15

 Ex: https://ap15.salesforce.com/services/oauth2/authorize?response_type=code&client_id=3MVG9G9pzCUSkzZsCPaAX8.zvESQV5hkzpV&redirect_uri=https://softwareag.com

11. The user gets logged into Salesforce, it redirects the user to the approval page. The user has to approve the access by hitting “allow

 12. After the user approves access, the user is redirected to the URI specified in, returns a query string containing code     (authorization code) and state.           

  1. Check if the obtained Authorization code encoded from salesforce or not.
    case i. If encoded it contains the characters “%253D%253D” at the end of the
    Authorization code string. If its encoded then the user needs to decode the Authorization
    code using any URL Decoder.
    Ex: URL Decoder/Encoder
    case ii. If not encoded then use the same Authorization code obtained from the Step 12.

 14. In Rest Client workspace (Ex: Postman) Set your HTTP request to POST ,input in the request url

  https://<instance_name>.salesforce.com/services/oauth2/token?grant_type=authorization_code&code={authorization_code}&

client_id={consumer_key}&client_secret={client_secret}&redirect_uri={callback_url}

    

 

 Note: Authorization code that the consumer must use to obtain the access and refresh tokens.The authorization code expires after 15 minutes.

 15. After filling in, the parameter values from Step 9&12, Click “SEND” button.

 16. Sample response looks as below containing Access and Refresh tokens

 17. Login to webMethods.io  and switch to webMethods.io flow editor from the app launcher

 18. Navigate to “Applications” > search for “Salesforce CRM” application

                                                             

 19. Click on “Add New Account” tab > specify the name of the Account

      

 20. Select the Authentication Type from the drop down as “OAuth V2.0(authorization code flow)”

      

 21. Fill the values for the parameters, generated from the above steps:- instanceClient id , Client secretAccess TokenRefresh Token

 22. Save the connection.

Note: Follow the Steps from 22 to configure a Salesforce Account in webMethods.io Integration

 23. Log in to webMethods.io integration tenant and create a workflow. Inside the workflow drag the Salesforce CRM app from the menu and click on the “setting” button.

     

 24. Choose the action from the predefined operation drop-down menu and click on the “+” sign to configure the new connection.

 25. Fill all the necessary credentials details and click on the Save button.

 26. Save the connection.

 27. Select the operation > select the buissness object > select fields > run the action created, the integration runs successfully.

I struggled with step 13 to post an authorization request and always failed with a message “invalid authorization code salesforce”.
Only to find that the given url from the callback had URL encoded characters like %25.
My code ended as %253D%253D which I replaced with %3D%3D.
Replacing the returned URL encoded characters with its equivalent characters made authorization post successful.

Which callback URL should I set? In your example, you use the SoftwareAG home page which doesn’t make sense to me.

Any valid URL for the callback is good. If you use the Software AG official website URL as the callback URL then it is this page that the Salesforce authentication will invoke and call to render as an output. It is not the rendered web page that is important but rather the extra code information that you’ll find in the URL of the rendered page.

Thanks for the reply. However I got error “redirect_uri must match configuration”.

I think this might be a Salesforce error. Please investigate the issue within the Salesforce knowledge base and the configuration that you have in your Salesforce account. More can be found by searching Salesforce and some of the results could be like as in DeveloperForce .