【问题标题】:FIrebase Google auth operation not supported in this environment此环境不支持 FIrebase Google 身份验证操作
【发布时间】:2016-12-01 22:57:43
【问题描述】:

我正在从事 ionic 和 firebase 项目,制作了一个登录页面以使用 google 登录。我在下面使用这个。

        var provider = new firebase.auth.GoogleAuthProvider();
        firebase.auth().signInWithRedirect(provider).then(function (result) {
            var token = result.credential.accessToken;
            // The signed-in user info.
            var user = result.user;
            $state.go('app.homepage');
        }).catch(function (error) {
        });

        firebase.auth().getRedirectResult().then(function (result) {
            if (result.credential) {
                var token = result.credential.accessToken;
            }
            // The signed-in user info.
            var user = result.user;
        }).catch(function (error) {
        });

当我在浏览器中运行它时,它工作正常,但是当我在 android 设备中运行它时,我得到了 auth/operation-not-supported-in-this environment。 该应用程序在“location.protocol”上运行。 我研究了一下,但找不到确切的答案。有什么问题?

【问题讨论】:

    标签: ionic-framework firebase firebase-authentication google-signin


    【解决方案1】:

    Ionic/Cordova 环境目前不支持弹出和重定向操作。作为后备,您可以使用 oauth cordova 插件来获取 google/facebook OAuth 访问令牌,然后通过 signInWithCredential 登录用户。查看此线程以了解更多信息:

    auth.signInWithCredential(firebase.auth.FacebookAuthProvider.credential(fbAccessToken));

    https://groups.google.com/forum/#!searchin/firebase-talk/facebook$20cordova/firebase-talk/mC_MlLNCWnI/DqN_8AuCBQAJ

    【讨论】:

    • 您好,我了解情况,但有一些疑问。我可以使用ngcordova.com/docs/plugins/facebook 这个插件来获取 facebook 访问令牌吗?同样在我的 facebook 应用程序页面中,我应该将平台放在移动端还是网站上?我正在使用 ionic
    • 您好 Missak,Firebase 不建议使用任何特定的 cordova 插件来获取 OAuth 访问令牌。最终,Ionic/Cordova 的 Web SDK 应该直接支持等效的 signInWithPopup。因此,在提供该功能之前,这更像是一个临时解决方案。
    【解决方案2】:

    尝试以下操作,因为 webView 中未启用本地存储,而这是 firebase 所必需的

    webSettings.setDomStorageEnabled(true);

    【讨论】:

      猜你喜欢
      • 2017-01-30
      • 1970-01-01
      • 1970-01-01
      • 2018-04-18
      • 2022-01-07
      • 1970-01-01
      • 2016-09-26
      • 2017-07-01
      • 2019-02-09
      相关资源
      最近更新 更多