OAuth in ServiceNow

veronica1
Kilo Contributor

Hi Experts,

Sorry if I am asking the same question again, but can someone please share some information on how OAuth works in ServiceNow?

Our implementation Consultant mentioned that OAuth can be used with REST integrations.

It will be helpful if someone can share something like "OAuth is Servicenow: for Dummies".

Thanks

Veronica

1 ACCEPTED SOLUTION

vab_13
ServiceNow Employee
ServiceNow Employee

Hi



posted same details in Outbound REST web service call using oAuth




I wrote this Doc a while back, have a read and you should be able to leverage OAuth for REST after this.


How to leverage OAuth for Integrations to ServiceNow



Summary:



STEP#1: under "System OAuth" -> "Application Registry" => Configure the application in ServiceNow instance: Create application


Make a note of:


<client_id> AND <client_secret>



STEP#2:   Request Access Token


Use the OAuth 2.0 API to construct an access token request.


Endpoint URL: <Your Instance>.service-now.com/oauth_token.do


Request format: All requests should format as a URL-encoded HTTP POST body.


Request parameters: Most request parameters are required.


Response format: JSON


Response parameters: The response contains one or more OAuth tokens.




REST Call Parameters:


grant_type:password


client_id:74c25ae08407a6002716dacdf5ac09e3


client_secret:test


username:admin


password:admin



Above Token request can also be done directly via Curl:


$ curl -d"grant_type=password&client_id=74c25ae08407a6002716dacdf5ac09e3&client_secret=test&username=admin&password=admin"


https://vabistanbul.service-now.com/oauth_token.do





3. Make a TEST REST Request with an OAuth Token:


- Token allows ServiceNow to identify which user is sending the request.


- All ACL applying to this user also apply to these requests.


- We will try to fetch one Incident record by using OAuth access Token:



REST Request will look like:



GET: https://vabistanbul.servicenow.


com/api/now/table/incident?sysparm_limit=1


accept:application/json


Authorization:Bearer


jsFh2_X3IxGJjm5D5hIllaufm0T9su6cjrJqdRgcx4lOQev8Ee0npP0NFTTyth0UUtn


Aabt89slgfvzky4FbMA


Note: ( Authorization:Bearer +Token string)




Curl:


curl -H "Accept:application/json" -H "Authorization:Bearer


jsFh2_X3IxGJjm5D5hIllaufm0T9su6cjrJqdRgcx4lOQev8Ee0npP0NFTT


yth0UUtnAabt89slgfvzky4FbMA" "https://vabistanbul.servicenow.com/api/now/table/incident?sysparm_limit=1




Hope this helps.



Docs:


OAuth 2.0 tutorial - create an OAuth provider and profile


View solution in original post

4 REPLIES 4

vab_13
ServiceNow Employee
ServiceNow Employee

Hi



posted same details in Outbound REST web service call using oAuth




I wrote this Doc a while back, have a read and you should be able to leverage OAuth for REST after this.


How to leverage OAuth for Integrations to ServiceNow



Summary:



STEP#1: under "System OAuth" -> "Application Registry" => Configure the application in ServiceNow instance: Create application


Make a note of:


<client_id> AND <client_secret>



STEP#2:   Request Access Token


Use the OAuth 2.0 API to construct an access token request.


Endpoint URL: <Your Instance>.service-now.com/oauth_token.do


Request format: All requests should format as a URL-encoded HTTP POST body.


Request parameters: Most request parameters are required.


Response format: JSON


Response parameters: The response contains one or more OAuth tokens.




REST Call Parameters:


grant_type:password


client_id:74c25ae08407a6002716dacdf5ac09e3


client_secret:test


username:admin


password:admin



Above Token request can also be done directly via Curl:


$ curl -d"grant_type=password&client_id=74c25ae08407a6002716dacdf5ac09e3&client_secret=test&username=admin&password=admin"


https://vabistanbul.service-now.com/oauth_token.do





3. Make a TEST REST Request with an OAuth Token:


- Token allows ServiceNow to identify which user is sending the request.


- All ACL applying to this user also apply to these requests.


- We will try to fetch one Incident record by using OAuth access Token:



REST Request will look like:



GET: https://vabistanbul.servicenow.


com/api/now/table/incident?sysparm_limit=1


accept:application/json


Authorization:Bearer


jsFh2_X3IxGJjm5D5hIllaufm0T9su6cjrJqdRgcx4lOQev8Ee0npP0NFTTyth0UUtn


Aabt89slgfvzky4FbMA


Note: ( Authorization:Bearer +Token string)




Curl:


curl -H "Accept:application/json" -H "Authorization:Bearer


jsFh2_X3IxGJjm5D5hIllaufm0T9su6cjrJqdRgcx4lOQev8Ee0npP0NFTT


yth0UUtnAabt89slgfvzky4FbMA" "https://vabistanbul.servicenow.com/api/now/table/incident?sysparm_limit=1




Hope this helps.



Docs:


OAuth 2.0 tutorial - create an OAuth provider and profile


if we are getting the token from third prty for evry api call, where csn we store that token.?