Facebook登录react-native&firebase 3.1

atl*_*teh 18 facebook firebase react-native firebase-authentication

最近firebase团队发布了新版本的firebase 3.1,它与react-native兼容.我正试图在facebook上使用新的firebase api.

由于firebase不支持react-native中的弹出或重定向,我使用react-native-fbsdk来获取访问令牌,但是当我尝试使用auth.signInWithCredential时,登录失败

代码:"auth/app-not-authorized",
消息:"此应用由托管的域识别,无权使用提供的API密钥使用Firebase身份验证.请在Google API控制台中查看您的密钥配置."

这是我的代码.任何帮助将非常感谢.

import { LoginManager, AccessToken} from 'react-native-fbsdk';
import firebase from '../Services/firebase';

const auth = firebase.auth();
const provider = firebase.auth.FacebookAuthProvider;

LoginManager.logInWithReadPermissions(['public_profile'])
.then(loginResult => {
    if (loginResult.isCancelled) {
        console.log('user canceled');
        return;
    }
    AccessToken.getCurrentAccessToken()
    .then(accessTokenData => {
        const credential = provider.credential(accessTokenData.accessToken);
        return auth.signInWithCredential(credential);
    })
    .then(credData => {
        console.log(credData);
    })
    .catch(err => {
        console.log(err);
    });
});
Run Code Online (Sandbox Code Playgroud)

atl*_*teh 6

我们设法找到了问题.似乎firebase给我们的凭据由于某种原因已经过时了.
从谷歌控制台我们发现,一个新的apiKey以某种方式生成(可能在升级到firebase 3?)并且firebase密钥被标记为Previous键.
一旦我们在应用程序中更新了新的apiKey,一切都开始工作了.

  • @JoeCaraccio有点晚了,但我在这里创建了一个facebook/firebase示例项目:https://github.com/J-Priebe/react-native-facebook-firebase (2认同)