
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
OAuth 2.0 lets users access instance resources through external clients by obtaining a token rather than by entering login credentials with each resource request.
The propose of this blog is to show how to trigger Rest integration secured by OAuth 2.0 using the Action Designer of Flow Designer. I am going to introduce two way how trigger Rest Integration using OAuth token:
1) Action Script;
2) Integration hub -Rest integration configuration.
Pre-requirement
For Rest integration configuration in the Action Designer, which requires the Integration hub plugins. I am going to perform this OAuth Rest integration using two ServiceNow Instances: Instance A (source) and Instance B (target).
OAuth 2 Client Register (Instance B)
First step is located to Application Registry (see blow) through Navigation Filter in Instance B.
Click "New" to create new record and fill "Name" filed and then click "Save". Three fields: Client ID, Client Secret and Redirect URL will auto populated. Please write down three field value for next step
Create OAuth 2 Provider Record
Located to Application Registry (see blow) through Navigation Filter in Instance A to create new OAuth provider record blow by filling the following fields:
- Client ID - from Instance B (above)
- Client Secret - from Instance B (above)
- Default Grant type - Authorization Code
- Authorization URL - https://dev94245.service-now.com//oauth_auth.do
- Token URL - https://dev94245.service-now.com/oauth_token.do
Create Outbound Rest Message
In instance A, create Outbound Rest Message blow-all fields highlighted by yellow. After you pick OAuth 2.0 in Authentication type field, please select OAuth profile value created from the above step and save this record.
Test OAuth 2 token
In Rest message you created in instance A, you click "Get OAuth Token" in related link and then another token window is popup. When you click "Allow" button, OAuth will allow you connect to instance B.
So far we have competed the configuration for both OAuth and Rest integration so next we are going to use the Action Designer of Flow Designer to configure and trigger the outbound Rest message to connect from Instance A to Instance B using OAuth 2 token security approach.
Action Script (Approach 1)
This approach is using the Action Script to call the Outbound Rest Message -Create OAuth Request created early rather than using REST configuration as a part of the Integration hub.
Step 1-Define new Flow Action in Action Designer by add "Script" action
Steps 2 -Copy the script from Rest Message previously defined
Step 3 - Paste the copied script into script action and defined Output variable -
Steps 4- Define Outputs and assigned the output variable -resResponse
Step 5 - Test your action to verify the results
You would find the Outbound Rest Integration configured by OAuth 2 is successfully called through the Action script of Action Designer from response output.
Rest Integration Configuration (Approach 2)
This approach requires the Integration hub plugins activation before we can use the Rest action in Action designer.
Step 1 - Activate Integration hub plugins
Step 2 - Define new Flow Action in Action Designer by add "REST" action
Step 3 - Define your connection to Instance B
You need to create Rest user access account to define the initial connection to the instance B
Step 4-Configure REST like blow:
Step 5 - Define output
Step 6 - Test your action to verify the results
Summary
I have demoed two approaches: 1) Action Script; 2) Action Rest to configure and trigger the Outbound Rest integration secured by OAuth 2 through the Action Designer. You can use either the Action REST (Integration hub plugin required) and Action Script (no additional requirement). This blog will strandline the Rest integration with OAuth implementation through Flow Designer so you can easily apply your flow to any ServiceNow Rest integration with OAuth secured.
If you like my post, please mark it as useful
- 11,361 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.