Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 05:39 AM
@Nikolay Mikheev This is very helpful, however, I cannot seem to get this to work. I can get this to work in Postman just fine. I define the Region and Service Name and the request goes through just fine. However, ServiceNow will generate an Authorization token to use, but when I use it in a request it doesn't work, it returns
"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."
Am I missing something? Below is the script I am using. I can manually add the what Postman generates into the Flow action and it works just fine.
var method = 'GET';
var service = 'nsm-service';
var region = 'us-west-2';
var credentialSID = '6db9679347c39d10ff7ca904846d4341';
var gdt = new GlideDateTime();
// Define the HttpRequestData object
var host = "nsm-service-corp.us-west-2.amazonaws.com";
var endpoint = "https://" + host;
var httpRequestData = new sn_auth.HttpRequestData();
var dateNum = gdt.getNumericValue();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setHost(host);
httpRequestData.setRegion(region);
httpRequestData.setService(service);
httpRequestData.setHttpMethod(method);
httpRequestData.setDate(dateNum);
// httpRequestData.addQueryParam('Action', 'ListUsers'); //we don't use any params
// httpRequestData.addQueryParam('Version', '2010-05-08'); //we don't use any params
var credential = (new sn_cc.StandardCredentialsProvider()).getAuthCredentialByID(credentialSID);
// Create the RequestAuthAPI object and sign the request
var signingAPI = new sn_auth.RequestAuthAPI(httpRequestData, credential);
var signMessage = signingAPI.generateAuth();
gs.log("Status is: " + signMessage.getStatus());
//------------------------------------------------------------------------
var headerMap = signMessage.getHeaderMap();
for(var x in headerMap) {
var y = headerMap[x];
gs.log('HeaderMap[' + x + ']: ' + y);
}