如何使用 Post 消息将 oAuth 代码从 Visualforce 页面发送到位于 2 个不同 Windows 上的 LWC 组件?

问题描述 投票:0回答:0

我是 salesforcce developement 的新手,尝试使用 oAuth Web 服务器流程集成两个 salesforce 组织,我正在将回调代码发送到 vf 页面,但是当我使用 post 消息将代码发送到 Lwc 时,它抛出以下错误

任何人都可以建议一种使用 Lwc 进行 oAuth Web 服务器流程的方法

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://bnthinc-8d-dev-ed.develop.lightning.force.com') does not match the recipient window's origin ('https://bnthinc-8d-dev-ed--testingbnth.develop.vf.force.com').

vf 页面中的代码以发布消息

<apex:page >

  <script>
    //window.top.postMessage(window.location.hash.substring(1),'https://bnthinc-8d-dev-ed.develop.lightning.force.com');
     parent.postMessage('Code','https://bnthinc-8d-dev-ed.develop.lightning.force.com');
  </script>

</apex:page>
Code in LWC to Catch Message

 doAuth(){

        let oAuthUrl=`${BASE_URL}?client_id=${client_Id}&redirect_uri=${redirected_Uri}&response_type=code`;
        window.open(oAuthUrl);

        window.onmessage((msg)=>{
            console.log('Data>>',msg.data);
            console.log('Message>>',msg);
        })
    }

我是 salesforcce developement 的新手,尝试使用 oAuth Web 服务器流程集成两个 salesforce 组织,我正在将回调代码发送到 vf 页面,但是当我使用 post 消息将代码发送到 Lwc 时,它抛出以下错误

任何人都可以建议一种使用 Lwc 进行 oAuth Web 服务器流程的方法

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://bnthinc-8d-dev-ed.develop.lightning.force.com') does not match the recipient window's origin ('https://bnthinc-8d-dev-ed--testingbnth.develop.vf.force.com').
javascript salesforce apex visualforce lwc
© www.soinside.com 2019 - 2024. All rights reserved.