Ram Bavireddi
Ram Bavireddi

Reputation: 1187

ServiceNow `OAuth 2.0` authorization endpoint and token endpoint

I want to integrate my application with ServiceNow using its REST API. For this, my app needs to get authorized using OAuth 2. I have searched for Authorization and Token endpoints in the wiki of ServiceNow, but could not find any.

Can anyone please post here those urls?

Upvotes: 4

Views: 7531

Answers (2)

Ram Bavireddi
Ram Bavireddi

Reputation: 1187

It seems ServiceNow supports only password and refresh_token grant types. Please see here. Authorization and Token urls are for Authorization code grant type.

Upvotes: 0

Bryan
Bryan

Reputation: 551

Starting with the Fuji release ServiceNow supports authenticating to REST endpoints using OAuth. First off, be sure to enable the OAuth plugin if it's not already enabled on the ServiceNow instance you are trying to integrate with. For information on how to do this and how to setup an OAuth endpoint check out these product docs.

Once you've created an OAuth endpoint in the application registry on your ServiceNow instance you'll need to generate tokens to use for authentication. You can find curl samples for generating tokens in the product docs. Review the response to the request you made to generate tokens and grab the 'access token'. The response from generating tokens should contain a JSON body similar to the following:

{"scope":"useraccount","token_type":"Bearer","expires_in":1800,"refresh_token":"w599voG89897rGVDmdp12WA681r9E5948c1CJTPi8g4HGc4NWaz62k6k1K0FMxHW40H8yOO3Hoe","access_token":"F0jh9korTyzd9kaZqZ0SzjKZuS3ut0i4P46Lc52m2JYHiLIcqzFAumpyxshU9mMQ13gJHtxD2fy"}

From the response you will want to record the 'access_token' and include it as a bearer token in subsequent requests to the ServiceNow REST API endpoints.

Sample request to REST Table API using the access token:

curl -H "Accept:application/json" -H "Authorization:Bearer 2wRlsRCT2SYjCCJP91kwo2EFzj5qg4O3I3aC09e0-0hz6Ib3YK7If-LMiNorNuglfqbkL4AfkYC92KYHUCcbpQ" "http://<instance>.service-now.com/api/now/table/incident"

Hope that helps!

Upvotes: 3

Related Questions