Javier_Colmeiro | 2023-11-13 16:52:14 UTC | #1
Hi all.
Been using embedded framework for a while and been able to interact between framework.js and a frontend system to catch messages like login, call accepted, call disconnected, etc to perform several frontend topics.
Now I would like to use API for some queue manipulation. I have this done and working using it's own external Oauth workflow but I was wondering if using embedded framework method getAuthToken is it possible to actually reuse login to perform API operations so user doesn't need to log in 2 times(embedded and frontend) and reuse tokens for some operations.
After looking at the documentation, forum and github example my code looks somewhat like this:
framework.js initialSetup: function () { window.PureCloud.subscribe([ ... window.addEventListener("message", function(event) { try { var message = JSON.parse(event.data); if(message){ ... }else if(message.type == "requestAuthToken"){ window.PureCloud.User.getAuthToken(function (token){ window.parent.postMessage(JSON.stringify({ type: "userActionSubscription", data: { category: "token", token: token } }), "*"); }); }
frontend_framework.js
if (message.type === 'userActionSubscription' && message.data.category === 'login') { // Scroll to the softphone iframe and focus it var softphoneIframe = document.getElementById('softphone'); console.log("sending request for TOKEN") softphoneIframe.contentWindow.postMessage({ type: "requestAuthToken" }, "*"); } if (message.type === 'authToken') { // Hande framework.js token response and do stuff self.updateAuthTokenInSystem(session.uid, message.token); }
My iframe definition has the url key to allow this kind of operations: iframe id="softphone" src="https://apps.mypurecloud.ie/crm/embeddableFramework.html?dedicatedLoginWindow=true&enableFrameworkClientId=true"/> The call to framework.js seems to work but then nothing happens, no error and framework.js doesn't return anything.
Any idea what I'm missing? Is there a way to debug framework.js received messages?
system | 2023-12-13 16:51:43 UTC | #2
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 23097