how to use external client oAuth access token in inbound scripted REST API

Sagaya1
Giga Expert

Hi,

I have created the external client oAuth access token through https://<instance>.service-now.com/oauth_token.do.

How do i use this access token in scripted REST api script for authentication ?

 

Regards,

Sagaya.

1 ACCEPTED SOLUTION

@Sagaya 

Glad to know that it worked.

Please close the thread as answered by marking my response as correct and helpful If I was able to help/guide you.

Regards
Ankur

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

View solution in original post

24 REPLIES 24

Hi Ankur,

Please find the details below.

Objective : Third party will use my API and access service now instance . For that i have created the "access_token" through  https://<instance A>.service-now.com/oauth_token.do.

Then trigger https://<instance A>.service-now.com/api/mamb/ivr through post man. in this API , instead of basic  authorization i need to use the oAuth 2.0.

But while i am trying to access the API by pass the oAuth access token , got 401 error.

Steps :

1. Created an OAuth API endpoint for external client in instance A

2. Created the scripted REST API for POST operation in service now. No authentication code written in the script in instance A.

3. In postman call https://<instance A>.service-now.com/oauth_token.do and get the access token .

4. pass the access token in postman POST request API header [Authorization : Bearer <access token value from https://<instance A>.service-now.com/oauth_token.do> and trigger the API which is available in instance A.

5.Response in instance A.

 responseBody:{"error":{"message":"User Not Authenticated","detail":"Required to provide Auth information"},"status":"failure"}

http response status_code: 401

Please help to fix this issue.

 

Regards,

Sagaya Rajan.

 

Hi Rajan,

Do you have any ACL applied to that Scripted REST API?

if yes and if that user using whose credentials you got the access token doesn't have access to it then it would fail

it should work fine for something like this

Scripted REST External Default

find_real_file.png

Regards
Ankur

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

Hi Ankur,

There is a default  ACL in my scripted REST API page .[Scripted REST service]. 

Please help to fix this issue.

find_real_file.png

 

Regards,

Sagaya Rajan.

@Sagaya 

Can you share screenshot of how you are calling the actual API with the bearer token.

Regards
Ankur

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

Hi Ankur,

 

Please find the below screenshot.

find_real_file.png

 

Regards

Sagaya