繁体   English   中英

Firebase Cordova Google登录不起作用

[英]Firebase Cordova Google Login not working

我阅读了这些文档https://firebase.google.com/docs/auth/web/cordova,并按照说明的所有步骤进行操作,没有错误,当应用程序从Google登录名重定向回时,出现了此错误。 我在Android手机上对此进行了测试。

code: "auth/redirect-cancelled-by-user"

message: "The redirect operation has been cancelled by the user before finalizing."

signIn的代码如下:

login(){
   let provider = new firebase.auth.GoogleAuthProvider();
   firebase.auth().signInWithRedirect(provider);
}

ngOnInit(){

  firebase.auth().getRedirectResult().then(function(result) {
    if (result.credential) {
      // This gives you a Google Access Token.
      // You can use it to access the Google API.
      var token = result.credential.accessToken;
      // The signed-in user info.
      var user = result.user;
      console.log(user);
      // ...
    }
  }).catch(function(error) {
    // Handle Errors here.
    var errorCode = error.code;
    var errorMessage = error.message;
    console.log(error);
   });

}

ionViewWillLoad(){

  firebase.auth().onAuthStateChanged(function(user) {
    if (user) {
      // User is signed in.
      console.log('Observer');
      console.log(user);
    } else {
      // No user is signed in.
    }
  });
}

我已经删除并安装了几次文档中指示的必需插件,但仍然遇到相同的错误。 凡是与Oauth合作使用Firebase和Cordova的人,请分享您的知识,我们将不胜感激!

进入config.xml并添加这两行

<preference name="OverrideUserAgent" value="Mozilla/5.0 Google" />

<allow-navigation href="*" />

第一个将解决用户代理问题,第二个将允许您将您重定向回您的应用程序。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM