FIrebase Google auth operation not supported in this environment

和自甴很熟 提交于 2019-12-21 20:58:31

问题


I am working on ionic and firebase project, made a login page to sign in with google. I am using this Below.

        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) {
        });

When I run it in the browser it is working fine, but when I run it in android device I am getting auth/operation-not-supported-in-this environment. The application is running on "location.protocol". I researched a bit but could not find an exact answer. What could be wrong ?


回答1:


popup and redirect operations are not currently supported in Ionic/Cordova environment. As a a fallback you can you an oauth cordova plugin to obtain a google/facebook OAuth access token and then sign in the user via signInWithCredential. Check this thread for more on this:

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

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




回答2:


Try the following because local storage is not enabled in webView, which is required for firebase

webSettings.setDomStorageEnabled(true);



来源:https://stackoverflow.com/questions/38621305/firebase-google-auth-operation-not-supported-in-this-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!