0

我按照这篇文章为使用 Firebase 作为后端服务的 Ionic App 创建了 OAuth。能够在 Ionic Lab 中调出应用程序,并且可以看到社交图标。但是当我点击任何图标时,什么都没有发生。

只知道我的代码使用了cordova-plugin-inappbrowser,我对此知之甚少。当我点击相应的图标时,我除了一个 Facebook 或 Twitter 弹出窗口来显示,但它似乎没有。

我在控制台中看到以下错误:

当我点击 Facebook 图标时:

Refused to display 'https://www.facebook.com/login.php?
skip_api_login=1&api_key=150011636022826…
&display=popup&locale=en_US&logger_id=fe62445f-81aa-405e-b35f-
80f8fd220707' in a frame because it set 'X-Frame-Options' to 'DENY'.

当我点击 Twitter 图标时:

Refused to display 'https://api.twitter.com/oauth/authenticate?
oauth_token=nSzk7gAAAAAAuTInAAABV456ulg' in a frame because an ancestor 
violates the following Content Security Policy directive: "frame-ancestors 
'self' https://tweetdeck.twitter.com https://tdapi-
staging.smf1.twitter.com https://tdapi-staging.atla.twitter.com 
https://tweetdeck.localhost.twitter.com".`

我该怎么做才能纠正这个问题?

当我手动执行时ionic serve,应用程序会在浏览器中加载,当我单击 Facebook 图标时,我可以将页面重定向到 Facebook 登录。

PS:我对这个 Ionic 框架只有一天的时间。

4

1 回答 1

1

找到解决方案并发布它,因为它可能对其他人有帮助:

我克隆项目的GITHub 链接。然后转到文件www/js/controllers.js,其中存在$scope.login()方法DashCtrl

Auth.$authWithOAuthRedirect(authMethod).then(function(authData) {
      console.log(authData);
    })

这是给出问题的片段,因为它试图重定向到不同的页面并且它在浏览器中运行良好,在 app/ionic lab 或任何东西中失败

如果您的工作特定于 Ionic 应用程序版本,请改为执行此操作:

Auth.$authWithOAuthPopup(authMethod).then(function(authData) {
          // after successfully logging in the user - do your magic stuff here
          console.log(authData);
        });
于 2016-10-04T12:02:09.017 回答