【问题标题】:Credential doesn't exist on Facebook AuthFacebook Auth 上不存在凭据
【发布时间】:2022-01-11 18:19:40
【问题描述】:

我从 expo 文档页面 Using Firebase (Facebook-Login) 复制此代码以将 Facebook 登录与 firebase 集成。

const { type, token } = await Facebook.logInWithReadPermissionsAsync({
                                  permissions: ['public_profile'],
                              });
      
if (type === 'success') {
    const facebookAuthProvider = new FacebookAuthProvider();
    const credential = facebookAuthProvider.credential();
}

但是当我复制它时,安装了所有依赖项时,它会说:

  • 属性'token' 不存在于类型'FacebookLoginResult'
  • 属性'credential' 不存在于类型'FacebookAuthProvider'

但是当我进入它们确实存在的节点模块时,idk 发生了什么或者如果我做错了什么,请帮助。

【问题讨论】:

    标签: firebase facebook-graph-api firebase-authentication expo facebook-javascript-sdk


    【解决方案1】:

    当你调用函数 signInWithCredentials 时,你还应该传递 auth 参数 你会得到的

    const auth = getAuth();
    
    // Listen for authentication state to change.
    onAuthStateChanged(auth, user => {
      if (user != null) {
        console.log('We are authenticated now!');
      }
    
      // Do other things
    })
    

    您还必须在 FacebookAuthProvider 中进行一些更改

     await initializeAsync({ appId: <PP_ID> });
    
        const { type, token } = await logInWithReadPermissionsAsync({
          permissions: ['public_profile'],
        });
    
        if (type === 'success') {
          const credential = FacebookAuthProvider.credential(token)
    signInWithCredential(auth, credential)
           .catch(error => console.log(error);
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-04
      • 2016-07-12
      • 2015-08-01
      • 2021-06-28
      • 1970-01-01
      • 1970-01-01
      • 2018-11-23
      • 2021-10-28
      相关资源
      最近更新 更多