How to implement rest message integration from script after generating token from get oauth token ui action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 01:00 AM
Hi All,
I have a requirement to integrate servicenow with a third party tool. So I am using REST with OAuth 2.0 authentication with grant type is resource owner password credentials(password) while implementing it.
Now what I did to implement is =
1. I have made a record in Oauth registry
2. Then created a new rest outbound and selected authentication type as Oauth 2.0 and selected desired oauth profile.
3. Now clicked on get OAuth token and it is asking me to input the user name and password, after filling user name and password, OAuth token is successfully generated.
4. After that i have tested my POST message and got the desired result.
Now the thing is I have to implement the same in script like in business rule or workflow script. So In case of basic authentication, we just call the rest message and get the desired output. In case of Oauth, the token expire in some 30 mins. So after that we are not manually click on get oauth token again and again to generate the token. So I found a script to generate the token and want to use the same token in the rest message to get the output from script.
Can any one of you tell me how to use the token while calling the rest post message if token is not generated from get OAuth token.
Please tell me the process , how to do it?
Thanks & Regards,
Vidit
josh.nerius Please comment.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 07:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 08:14 AM
Hi Harsh,
Can we use this curl script in business rule or in back ground script.??
Thanks,
Vidit

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 10:24 AM
yes you can use that.
please check the link below.
python - Adding a curl request into a serviceNow business rule (javascript) - Stack Overflow