Ionic Firebase GooglePlus Auth

时间:2017-12-26 03:42:05

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

我正在为我的应用开发Google身份验证 我选择谷歌用户时遇到问题,该应用程序无法登录 我在firebase中看到数据库没有添加帐户。 模拟器运行时的提示有效,但是当我点击没有任何反应时。

 export class LoginPage {
  form: FormGroup;
  loginError: string;
  userProfile: any = null;
  constructor(
    public googleplus: GooglePlus,
    private navCtrl: NavController,
    private auth: AuthService,
    fb: FormBuilder
  ) {
    this.form = fb.group({
      email: ['', Validators.compose([Validators.required, Validators.email])],
      password: ['', Validators.compose([Validators.required, Validators.minLength(6)])]
    });
    firebase.auth().onAuthStateChanged( user => {
      if (user){
        this.userProfile = user;
      } else {
        this.userProfile = null;
      }
    });
  }

  signInWithGoogle() {
    this.googleplus.login({
      'webClientId': 'MYID3842ETC.apps.googleusercontent.com',
      'offline': true
    }).then( (res) => {
      if (!firebase.auth().currentUser) {
        firebase.auth().signInWithCredential(firebase.auth.GoogleAuthProvider.credential(res.idToken))
          .then(() =>
            this.navCtrl.push(TabsPage)
          )
      }
    })
  }

HTML

  <button ion-button clear full color="light" (click)="signInWithGoogle()" *ngIf="userProfile">
            <ion-icon name="logo-googleplus"></ion-icon>
            Login with Google
          </button>

NPM已安装

npm install --save @ionic-native/google-plus

cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=XXXXXXXXXXXXXXX

控制台错误:

  

D / CordovaActivity:传入结果。请求代码= 77552 D / CordovaInterfaceImpl:将活动结果发送到插件I / GooglePlugin:在onActivityResult I / GooglePlugin:我们的一项活动结束了I / GooglePlugin:处理登录结果I / GooglePlugin:没有在D / CordovaActivity中签名:恢复了活动。 D / SystemWebChromeClient:file:///android_asset/www/build/vendor.js:Line 1704:ERROR I / chromium:[INFO:CONSOLE(1704)]&#34; ERROR&#34;,source:file:// /android_asset/www/build/vendor.js(1704)

0 个答案:

没有答案