11-29-2021 08:40 AM - edited 11-29-2021 08:42 AM
Hello Everyone,
I'm using the Cisco Finesse - External REST API Sample Gadget to send credentials from Finesse to a URL in a GET request every time an agent answers a call. I am a little stuck in step 4, where the Gagdet's documentation specifies how to use the Authorization Header.
4. If the external REST API requires an authorization header, uncomment the line of code that adds the authorization to the options object. If the authorization type is Basic Auth, then you can skip to the next step.
Document link for reference: https://github.com/CiscoDevNet/finesse-sample-code/blob/master/ExternalRestApiSampleGadget/README.md
I did uncomment the line of code specified, now I am not certain how the credentials will be included in the authorization field of the options object (finesse.gadget.Config?).
Thanks in advance for the assistance provided on this!
Kenny
11-29-2021 11:20 AM
Kenny,
I believe the assumption in the example gadget if using authorization, is that the same authorization to log into Finesse is used to access the REST API.
If you have a look at this Link - it shows you how to get the login details / authorization of the logged in user:
And this is what the example gadget is doing.
If you want to send different authorization - set the header accordingly.
Here is some details and background on how to set basic auth.
Background
https://en.wikipedia.org/wiki/Basic_access_authentication
How to encode Base64-encoded ASCII
https://developer.mozilla.org/en-US/docs/Web/API/btoa
Example:
https://www.codegrepper.com/code-examples/javascript/basic+authentication+header+javascript
Regards,
Gerry
12-01-2021 08:11 AM
Hi Gerry,
Thanks for your response. You are correct, I am actually trying to send a different authorization, in this case where should I include the piece of code from https://www.codegrepper.com/code-examples/javascript/basic+authentication+header+javascript in the gadget code?
Thanks again,
Kenny
12-01-2021 09:10 AM
Hi Kenny,
You need to change the authorization line to something similar to the one found in your link.
Change:
authorization: _util.getAuthHeaderString(finesse.gadget.Config),
authorization: "Basic " + finesse.utilities.Utilities.b64Encode(username + ":" + password),where the username variable is the user's username and the password variable is the user's password. Of course you should not be hardcoding this information in the JS, so you will need to retrieve this data somehow.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide