How to use OAuth Bearer Token in Outbound Soap Web Service?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2014 09:05 AM
Hi,
We need to call a SOAP web-service in servicenow by which we need to post some data. That SOAP web-service is using OAuth authentication. We need to pass Authentication type as Bearer. But we are not able to do that.
Thanks,
Akash Rajput
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2014 10:22 AM
Realize you are using SOAP, but this article on REST should help:
Using OAUTH Tokens with REST Interfaces
Basically you need to pass in a new header:
Web Service Consumer Support - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2017 06:42 AM
Have anyone managed to get an oAuth token they can use to manually talk to a SOAP service?
I was hoping ServiceNow SOAP implementation supported oAuth as it does with REST but that is not the case.
I have problems getting an access token using https://api.cisco.com/pss/token - it complains that the client is invalid.
I can get it to work using curl:
curl -d "grant_type=client_credentials&client_id=7f…vv&client_secret=Na…Qc" https://api.cisco.com/pss/token
But when I try to do the same thing inside ServiceNow with the following code:
var sm = new sn_ws.RESTMessageV2();
sm.setEndpoint('https://api.cisco.com/pss/token');
sm.setHttpMethod('post');
sm.setQueryParameter('grant_type', 'client_credentials');
sm.setQueryParameter('client_id', '7f…vv');
sm.setQueryParameter('client_secret', 'Na…Qc');
var response = sm.execute();
I get the following responses:
- response.getStatusCode() returns: 401
- response.getErrorMessage() returns: Method failed: (/pss/token/) with code: 401 - Invalid username/password combo
- response.getBody() returns: {"error":"invalid_client"}
I tried to add sm.setRequestHeader('Accept', 'application/json'); before performing the execute() but that also did not make any difference.
I've tried using GlideHTTPRequest() and get the same result