Google身份验证操作

Google身份验证操作

本文介绍了此环境中不支持FIrebase Google身份验证操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发离子和firebase项目,登录页面使用谷歌登录。

  var provider = new firebase.auth.GoogleAuthProvider(); 
firebase.auth()。signInWithRedirect(provider).then(function(result){
var token = result.credential.accessToken;
//登录的用户信息
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;
}
//登录的用户信息
var user = result.user;
})。catch(function(error){
});

当我在浏览器中运行它时工作正常,但是当我在android设备上运行它时我在这个环境中获得了auth / operation-not-supported。
应用程序正在location.protocol上运行。
我研究了一下,但找不到确切的答案。什么可能是错误的?

解决方案
弹出和重定向操作当前不支持在Ionic / Cordova环境中。作为后备,您可以使用oauth cordova插件获取Google / Facebook OAuth访问令牌,然后通过signInWithCredential登录用户。检查此线程的更多信息:

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

$ 20cordova / firebase-talk / mC_MlLNCWnI / DqN_8AuCBQAJ


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 ?

解决方案

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

这篇关于此环境中不支持FIrebase Google身份验证操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 10:38