1

我已关注博客并使用 forcejs 插件在我的 ionic 混合应用程序中进行 salesforce 身份验证。我能够登录并在弹出 URL 中(重定向到回调后)我可以看到访问令牌。但是当弹出窗口来到回调 url 时,它不会自动关闭,而且我的回调函数也没有被调用。而且我无法使用身份验证结果。

  let appId = 'consumer_key';
  let loginURL = 'https://login.salesforce.com/';
  let oauthCallbackURL = 'http://localhost:8100/callback';


  let oauth = OAuth.createInstance(appId, loginURL, oauthCallbackURL);
  console.log('=============oauth: ', oauth)

  oauth.login().then(oauthResult => {
          //can not get here after authentication
          DataService.createInstance(oauthResult);
          console.log("Logged Into Salesforce Successfully");
  });
4

1 回答 1

2

使用http://localhost:8100/oauthcallback.html作为回调

在您的应用程序的根目录下,创建 oauthcallback.html

<html>
  <body>
   <script>
     var event = new CustomEvent("oauthCallback", {'detail': 
     window.location.href});
     window.opener.document.dispatchEvent(event);
     window.close();
  </script>
 </body>

于 2017-10-19T18:39:10.857 回答