How to create Api with oauth so any other third party tool can consume

Debasis Pati
Kilo Sage

Hello All,
I want to expose one api with one thirdpart tool but it should also have ouath as authenticaion method.

How i should create this?

Any idea @Ankur Bawiskar ?

1 ACCEPTED SOLUTION

@Debasis Pati 

you are using GlideRecordSecure so it will evaluate ACL and ACL must be blocking the READ Access

Please use GlideRecord and it will work fine with Postman

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

12 REPLIES 12

Hello @Debasis Pati 

You do not pass the Refresh Token to your Incident API, and you do not write code inside your script to validate the token. ServiceNow handles the validation for you automatically before your script ever runs.

Happy to help! ‌‌
To help others in the community find this solution, kindly mark this response as the Correct Answer ‌‌ and Helpful‌‌.
Warm Regards,
Deepak Sharma
Community Rising Star 2025

Ankur Bawiskar
Tera Patron

@Debasis Pati 

From Washington release there was an addition and you can use Client Credentials

check below blog and do setup

Up Your OAuth2.0 Game: Inbound Client Credentials with Washington DC              

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello @Ankur Bawiskar ,
i already have the username and password setup done and able to successfully bring the token.
Next what i want is incident details for settinbg up that api which should accept the number and provide the incident details in response using the token is the scenario.
Getting token yes i am already getting it .
Let me know what the api setup which will send the incident details in response.

@Debasis Pati 

it's an easy requirement. you will find lot of blogs or articles for this

ask them to include INC number in GET header API and then query and send response

something similar I shared earlier, you can check and enhance

scripted rest api to get all incidents assigned to user groups? 

you can also take of any AI to get the sample script etc

AnkurBawiskar_0-1770877497258.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello @Ankur Bawiskar ,

I did it but the problem is when i used rest api explorer after creating resource and the api endpoint it is giveing me the details of the incident .
The same i tried in post man with the oauth 2.0 and by providing the access token then i am getting the below error-

"result": {
        "error": "Incident not found with number: INC0010485"
    }  

404 -Not found error.

also i tried with bearer token also same result