Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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,

Are you sending token in this manner

Authorization <AccessToken>

Regards
Ankur

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

Hi Ankur,

Tried but still getting same error.

find_real_file.png

Regards

Sagaya

Hi,

Did you give the Authorization value as this?

Bearer <AccessToken>

refer image below

find_real_file.png

Regards
Ankur

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

Hi Ankul ,

Yes I have given and still got different error and 401 error.

Step1 :

Get access token

find_real_file.png

Step 2:

Pass it in the POST API 

find_real_file.png

In the scripted REST API script , I have called the table API and got 401 error while servicenow tried to execute that table API.

23:57:25.978 *** Start #207214 /api/mamb/ivr, user: sagaya.r.stephen

23:57:26.9 reqheader : message_id-->Test

23:57:26.9 reqheader : channel_id-->ivr

23:57:26.10 MSISDN : 60123456781

23:57:26.11 MSISDN value : mobile_phone=60123456781

23:57:26.11 IVR Interaction validation : {" Message Id" :"Test" ,"Channal Id" :" ivr" }

23:57:26.12 contactTableEndPoint: https://dev.service-now.com/api/now/table/customer_contact?mobile_phone=60123456781

23:57:26.126 httpStatus:401

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

23:57:26.128 [DEBUG] http response status_code: 401

 

But when i use the basic authorization its working fine.

So while use the oAuth , dont use any other API inside the scripted REST API script ?

 

 

 

Regards,

Sagaya.

 

 

 

 

@Sagaya 

seems issue with the scripted rest API or the content type being sent over Postman

Regards
Ankur

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