React中的Firebase - signInWithPopup()返回一个空白页面

时间:2016-11-07 14:39:01

标签: reactjs firebase google-oauth firebase-authentication

我想使用google auth尝试使用firebase进行同一项目。

在我的反应项目中,我有一个带有此onPress功能的按钮=>

import firebase from 'firebase';
const provider = new firebase.auth.GoogleAuthProvider();

handleLogIn() {
    firebase.auth().signInWithPopup(provider)
    .then((result) => {
      // ...
    })
    .catch(function(error) {
      // ...
    });
  }

但这会返回一个空白页......任何建议?

更新:使用signInWithRedirect()可以正常工作

2 个答案:

答案 0 :(得分:0)

如果用户已登录并已为应用程序提供所需权限,则会打开和关闭空白页。在这种情况下,应用程序只返回数据。

答案 1 :(得分:0)

handleLogIn(e) {
    e.preventDefault() ;
    firebase.auth().signInWithPopup(provider)
    .then((result) => {
      // ...
    })enter code here
    .catch(function(error) {
      // ...
    });
  }