cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1361
Views
22
Helpful
19
Replies
Beginner

Workflow HTTP Post with Authorization in the header?

I need to create a workflow to consume a REST resource. JSON specifically as the body. My REST service requires a static authentication header in normal base64 encoding, however, I don't see the availability to add to the header in the Finesse workflow configuration. Is this possible? If so how?

Everyone's tags (4)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Cisco Employee

Re: Workflow HTTP Post with Authorization in the header?

Hi,

If the "Location" is set to "Other" as you have shown your previous post, an authentication modal will appear when the workflow gets triggered:

basic auth http request workflow.jpg

The user will have to enter the authentication. If the authentication is correct, the HTTP request will be executed. If the authentication is not correct, the authentication modal will reappear, giving the user another chance to enter the correct credentials (an infinite amount of times). If the "Cancel" button is pushed, the HTTP request will not be executed.

Just for information, if the "Location" is set to "Finesse", the logged in Finesse user's credentials will be used for authentication.

Thanx,

Denise

View solution in original post

19 REPLIES 19
Highlighted
Contributor

Re: Workflow HTTP Post with Authorization in the header?

The first question, is are you calling your service from a Finesse custom gadget?

Because of issues with CORS and cross site scripting security issues, you should use

gadgets.io.makeRequest

Highlighted
Beginner

Re: Workflow HTTP Post with Authorization in the header?

I was just doing a HTTP Request from the Finesse Workflow administrator. Not a gadget. example.png

I need the authenticationType header described here https://developer.cisco.com/media/finesseDevGuide2/CFIN_RF_W47F8918_00_workflowaction-api-parameters.html

Highlighted
Contributor

Re: Workflow HTTP Post with Authorization in the header?

The type is Basic.

Here is an example of setting up a screen pop workflow...

Cisco Finesse: How to Create a Screen-Pop Workflow - Cisco

Highlighted
Beginner

Re: Workflow HTTP Post with Authorization in the header?

I understand and want BASIC, however even if I turn on the authorization field (UCCX). I get no Authorization header in the request.

Highlighted
Cisco Employee

Re: Workflow HTTP Post with Authorization in the header?

Hi,

If the "Location" is set to "Other" as you have shown your previous post, an authentication modal will appear when the workflow gets triggered:

basic auth http request workflow.jpg

The user will have to enter the authentication. If the authentication is correct, the HTTP request will be executed. If the authentication is not correct, the authentication modal will reappear, giving the user another chance to enter the correct credentials (an infinite amount of times). If the "Cancel" button is pushed, the HTTP request will not be executed.

Just for information, if the "Location" is set to "Finesse", the logged in Finesse user's credentials will be used for authentication.

Thanx,

Denise

View solution in original post

Highlighted
Beginner

Re: Workflow HTTP Post with Authorization in the header?

I have got the location set to "other" but do not get the Authentication Modal screen. I'm using Finesse 11.5 with UCCE.

 

TBH this is no use to my customer  as I need the authentication to happen in the background. Has anybody created a custom gadget where I can hard code the authentication credentials?

Highlighted
Contributor

Re: Workflow HTTP Post with Authorization in the header?

Boyd,

That auth popup was a bug and should not occur if the server has been updated.
i.e. it send the post to the backend server without the end user having to do anything.
That is an old post and not accurate.

However if your backend server requires authentication - this might be an issue and that would likely require a custom gadget.

Gerry
Highlighted
Cisco Employee

Re: Workflow HTTP Post with Authorization in the header?

Hi Boyd,

 

Gerry is correct that it was a bug.

 

If you are looking for a sample on how to do a REST request with Authentication, the closest will be the ExternalRestApiSampleGadget:https://github.com/CiscoDevNet/finesse-sample-code/tree/master/ExternalRestApiSampleGadget

 

It doesn't actually have it done, but you can easily modify the code:

params[gadgets.io.RequestParameters.HEADERS].Authorization = options.authorization;

 

Another sample gadget to look at is the WorkflowScreenPopSampleGadget: https://github.com/CiscoDevNet/finesse-sample-code/tree/master/WorkflowScreenPopSampleGadget which allows you to change the workflow to "handle by: Other" and have the gadget handle it for you. This way you can still utilize the ease of the workflow, but be able to execute it with the custom gadget.

 

Thanx,

Denise

Highlighted
Beginner

Re: Workflow HTTP Post with Authorization in the header?

Thanks Denise and Gerry, 

 

I will have a look at the sample code and see if I can work out what to do.

 

Best Regards

 

Boyd

Highlighted
Beginner

Re: Workflow HTTP Post with Authorization in the header?

Hi Denise,

 

Can you please tell me how I would access the User Object from within handleNewDialog = function(dialog) function.

 

I need the User.loginName for the contentBody as that is one of the values I want to POST to our API.

 

Best Regards

 

Boyd

Highlighted
Cisco Employee

Re: Workflow HTTP Post with Authorization in the header?

Hi,

 

If you used one of the sample gadgets, you should have the user object that was created in the init function. But, loginName isn't a method that was exposed via the JavaScript API. You can get the agentId via user.getId. If you want the login name, you have to get it from the data itself. So you have to do user.getData, then parse the object for the loginName.

 

init : function () {

...

    user = new finesse.restservices.User({
        id: cfg.id,
        onLoad : handleUserLoad,
        onChange : handleUserChange
    });

}

 

Thanx,

Denise

Highlighted
Beginner

Re: Workflow HTTP Post with Authorization in the header?

Thanks Denise,

Would I be able to use this syntax? (Unfortunately I am not on-site today so cannot test it)

user.getData().loginName

You mentioned it in this post.

https://community.cisco.com/t5/contact-center/finesse-js-library-get-login-name/m-p/3433461#M876

Best Regards

Boyd
Highlighted
Cisco Employee

Re: Workflow HTTP Post with Authorization in the header?

Hi,

 

I don't have a working system to test that right now, but if I said it in another post, I'm going to guess that I had tested it at that time. That looks right though.

 

Thanx,

 

Denise

Highlighted
Beginner

Re: Workflow HTTP Post with Authorization in the header?

Hi Denise,

 

I managed to test it today and the code to get the agent's loginName works perfectly. Thanks for your help.

 

Unfortunately I don't appear to be able to connect to the our API server as shown below.

 

ExternalRESTAPISampleGadget : handleResponse(): The response status code is: 500

 

I think that this may be due to an invalid certificate as I had the same problem with Postman until I copied the certificate to my Trusted Root Certification Authorities. I have uploaded the certificate to Finesse but will need to start Tomcat OOHs.

 

As time is of the essence Is there anyway that I can tell the 3rd party gadget to ignore the certificate like we can do in Call Studio. Also are there any other attributes in the response object  below that will give us a text description of the error 500

 

handleResponse = function(handlers) {
return function (response) {
clientLogs.log("handleResponse(): The response status code is: " + response.rc);

 

FYI

When I call the same API from a Workflow I get

 

<div id=\"content-header\">HTTP Status 500 - javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated            </div>            <p>                <b>                    type:               </b> Status report            </p>            <p>                <b>message:               </b> javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated            </p>            <p>                <b>description:               </b> The server encountered an internal error that prevented it from fulfilling this request.    

 

 

Best Regards

 

Boyd

 

 

 

 

 

 

 

 

CreatePlease to create content