Configure Oauth with a Third party(salesforce) Oauth Provider.


Description

Description


In order to Set up Oauth between Saleforce and ServiceNow we have to follow the below: 

  • Create a Connected App in Salesforce for ServiceNow. 
  • Use the information obtained from the above step and configure ServiceNow. 

Step 1: Create a Connected Salesforce App:

  • Sign In to your Salesforce.com Developer account, Click on setup. 

                                  

  • From the left navigation Column, Under App Setup, Select Create --> Apps. 

                                  

  • In the Connected Apps Section, Click on New.

  • Complete the Basic Information, In the API Section Select Enable Oauth Settings. 
  • In the OAuth setting that appear, For Callback URL, Type the fully qualified domain name of your server, and append the URL by the following text: auth/add_oauth_token.

                 ex: https://<servicenow-instance>/auth/add_oauth_token

  • Move the following items from Available Oauth to select OAuth Scope:

                           * Access and manage your data(api)

                           * Access your basic Information(id)

                           * Perform request on your behalf at any time(refresh_token)

  • Click Save.

After you Save the app, Salesforce populates the API Section with the following IDs that will be used for the configuration on the ServiceNow Instance:

Make a note of the following: 

               * Consumer Key

               * Consumer Secret

               * Callback URL.

Step 2: Configuration on the Servicenow Instance: 

  • Search from System Oauth, Go to Application Registry --> New --> Connect to a third party OAuth Provider. 

  • Fill in the details on the form for application registry.

  • Enter the Client Secret and the Client ID generated on the salesforce in Step 1. 
  • Fill in the URL as below: 

                 * Authorization URLhttps://<salesforce domain>/services/oauth2/authorize 

                 * Token URLhttps://<Salesforce Domain>/services/oauth2/token

                 * Redirect URL: https://<servicenow domain>/oauth_redirect.do

  • Click on Update.

 Note: The salesforce domain in the above has to be replaced with the fully qualified domain name of your salesforce i.e appended with -dev-ed.my.salesforce.com

Get the OAuth token: 
  • From System Web Services --> Outbound --> REST Message. 
  • Create a new REST message: 

  • Type the Endpoint to make a Outbound REST in my case : https://anshulsnow-dev-ed.my.salesforce.com/services/data/
  • Click on Get OAuth Token. 
  • You will be redirected to the salesforce page and will be prompted for credentials. 
  • After successful authentication you will receive the OAuth token . 
  • You could verify the same from System OAuth --> Manage Token and verify that you see the token from salesforce. 


Additional Information


To Get the salesforce Developer account register on: https://developer.salesforce.com/signup

To set up the domain on Salesforce refer: https://help.salesforce.com/articleView?id=domain_name_overview.htm&type=5