OAuth Static Link Report

I am working on pulling report data from a static link to serviceNow, and I implemented it in serviceNow. I referred the link Generate static link - Genesys Cloud Resource Center (mypurecloud.com), I got error 400, and the error message is "Only one auth mechanism allowed; only the X-Amz-Algorithm query parameter, Signature query string parameter or the Authorization header should be specifiedAuthorizationBearer ....". Any ideas? What should I do to solve it?

Thank you!

It sounds like your request to receive the contents of the static link contains multiple authentication headers. You should look at the request that you are sending to make sure that you are not sending the a combination of the 3 items given in the error message. For example, if your request contains the Signature query string parameters AND the HTTP Authorization header, then you probably need to remove one or the other.

Thank you for your response. Yes, I think you are right. I am using the static link that like https://apps.<mygenesys.cloud>/platform/api/v2/downloads/09wtqywey44342q. From the error I received, it should already contains the Signature query string parameters AND the HTTP Authorization header. After I removed Authorization header, I got 200 code, and the received response that doesn't contains cvs content, but a list of cloudfront.net links. They look like the auth-service links for different customer devices. I am not sure.
What should I do to get cvs response? Thanks!
By the way, is it possible to use Rest API Call to download through the static link?

OK, I was able to duplicate what you are seeing. Your call to GET https://apps.<mygenesys.cloud>/platform/api/v2/downloads/09wtqywey44342q requires an OAuth access token from your Genesys Cloud org to be sent in the Authorization header as a bearer token. If you just try to perform a GET request on that URL without any Authorization header then you are going to get back the output that you described.

Try performing an OAuth Client Credentials grant authentication request to get an access token. Put that access token into the Authorization header of your request with a value in the format of "bearer <your_access_token_here> and then try to send it. You should then get the CSV output returned.

I am not sure how  familiar you are with ServiceNow, the following is what I am scripting there:

    var oAuthClient = new sn_auth.GlideOAuthClient();
    var params = {grant_type:'client_credentials', username:'<client_id>', password:'<client_secret>'};
    var json = new global.JSON();
    var text = json.encode(params);
    var tokenResponse = oAuthClient.requestToken('<OAuth2 Provider name>', text);
    var token = tokenResponse.getToken();
    var accessToken = token.getAccessToken();

var request = new sn_ws.RESTMessageV2(); // Using ServiceNow RESTMessageV2 API
request.setFollowRedirects(false);
request.setHttpMethod('get');
request.setEndpoint('https://apps.<mygenesys.cloud>/platform/api/v2/downloads/09wtqywey44342q');
request.setRequestHeader('Authorization','Bearer '+ accessToken);

// request.setAuthenticationProfile('OAuth2','<sn_sys_id>');
response = request.execute();
var httpStatus = response.getStatusCode();
var csvData = response.getBody();

about the 2 lines code here:
request.setRequestHeader('Authorization','Bearer '+ accessToken);
// request.setAuthenticationProfile('OAuth2','<sn_sys_id>');

no matter which one I use here, either or both, would generate the same error.

Unfortunately I have no experience with ServiceNow. I can't see anything obvious that sticks out in your code.

The only think I might suggest is to try and use a tool like Postman to send that request with the access token in the Authorization header. I think you'll see that it works.

Then maybe you can use a tool like RequestBin where instead of sending your API request to Genesys you can send it to RequestBin from both Postman and ServiceNow and compare the request being sent. Then maybe you can discover some difference between the two and resolve the difference in your code.

Thank you! I tested the link with Postman. It works fine. It maybe something related to serviceNow.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.