oauth set up
https://docs.servicenow.com/bundle/tokyo-api-reference/page/integrate/inbound-rest/task/t_EnableOAuthWithREST.html
Procedure
Activate the OAuth 2.0 plugin.
Set the system property com.snc.platform.security.oauth.is.active to true.
Navigate to System OAuth > Application Registry.
Click New and then click Create an OAuth API endpoint for external clients.
Record the client_id and client_secret values from the previous step to use when requesting an access token.
To get an access token, use your REST client, such as cURL or Postman, to send a request to the OAuth endpoint (oauth_token.do).
Format the request as a URL-encoded HTTP POST body and include the required parameters.
Record the access token and refresh token from the response.
Submit the access token with subsequent REST requests.
https://docs.servicenow.com/bundle/tokyo-api-reference/page/integrate/inbound-rest/reference/r_RESTOAuthExample.html
servicenow inbount API response :
https://docs.servicenow.com/bundle/vancouver-api-reference/page/app-store/dev_portal/API_reference/ScriptableServiceResponseBuilder/concept/c_ScriptableServiceResponseBuilder.html
oauth profile need to be set up as useraccount
ServiceNow Oauth example: https://docs.servicenow.com/bundle/washingtondc-api-reference/page/integrate/inbound-rest/reference/r_RESTOAuthExample.html
In this example, the OAuth token has a client_id of a329c4515612210071a5e0c298ee2be8 and a client_secret of password22.
Getting an access token
Explain this code
curl -d "grant_type=password&client_id=a329c4515612210071a5e0c298ee2be8&client_secret=password22&username=RESTUser&password=RESTUserPassword" https://<instance>.service-now.com/oauth_token.do
Sample token response
Explain this code
{
:"scope": "useraccount",
:"token_type": "Bearer",
:"expires_in": 1799,
:"refresh_token": "jZPdkEVrWvtMjrspldNjIS0uWM4D7QV9mgmcQXDVo5Qa_GVvmdR6NOp7OM038EHJnd6nZpWocFer1NcJz4zwdw",
:"access_token": "2wRlsRCT2SYjCCJP91kwo2EFzj5qg4O3I3aC09e0-0hz6Ib3YK7If-LMiNorNuglfqbkL4AfkYC92KYHUCcbpQ"
}
REST request with OAuth token
Explain this code
curl -H "Accept:application/json" -H "Authorization:Bearer 2wRlsRCT2SYjCCJP91kwo2EFzj5qg4O3I3aC09e0-0hz6Ib3YK7If-LMiNorNuglfqbkL4AfkYC92KYHUCcbpQ" "https://<instance>.service-now.com/api/now/table/incident
No comments:
Post a Comment