Expo Firebase Facebook日志错误:auth / invalid-credential

时间:2020-10-17 08:42:57

标签: firebase react-native firebase-authentication expo facebook-login

我正在构建一个expo react-native应用程序,并尝试添加Facebook登录方法。

我在developers.facebook.com中创建了一个应用,并添加了IOS和Android平台,如下所示: enter image description here

在firebase中,我启用了Facebook身份验证,并添加了APP ID和APP secret。 将OAuth重定向URI复制到我的Facebook应用程序配置中

enter image description here

  • facebook登录应该为绿色吗?

然后在我的代码中执行以下操作:

async function loginWithFacebook() {
    try {
        await Facebook.initializeAsync({
            appId: '3433583816677371',
          });
        const {type, token } = await Facebook.logInWithReadPermissionsAsync({permissions: ['public_profile'],});
        if (type === 'success') {
            console.log('user has suuccceeeded his login ');
            console.log('type and token', type, token)
          const response = await fetch(`https://graph.facebook.com/me?access_token=${token}`);
          Alert.alert('Logged in!', `Hi ${(await response.json()).name}!`);
            const facebookCredential = firebase.auth.FacebookAuthProvider.credential(token)
            // Sign-in the user with the credential
            console.log('cred', facebookCredential)
            firebase.auth().signInWithCredential(facebookCredential).catch(error => {
                console.log('error siginig innnnn', error.code);
            });
        } else {
          console.log('user has cancelled his login ');
        }
      } catch ({ message }) {
        console.log('user has cancelled his login ', message);
        }
}

我获得了所有凭据,因此,它在firebase.auth()。signInWithCredntial(...)中失败,并且出现以下错误:

  • auth / invalid-credential

我遵循了文档,但是我不知道为什么它会失败!

任何帮助,请??

0 个答案:

没有答案