Javascript 世博会:;在此环境中不支持身份验证/操作”;

Javascript 世博会:;在此环境中不支持身份验证/操作”;,javascript,firebase,react-native,firebase-authentication,expo,Javascript,Firebase,React Native,Firebase Authentication,Expo,我开发了一个react native(expo)移动应用程序,并尝试使用google帐户登录firebase,但出现了一个错误: 此环境不支持身份验证/操作。此应用程序运行的环境不支持此操作。“location.protocol”必须是http、https或chrome扩展,并且必须启用web存储 代码: 在react native中不支持使用弹出式登录。您需要使用第三方OAuth库获取OAuth ID令牌或访问令牌,然后使用Firebase登录: const cred = firebase.a

我开发了一个react native(expo)移动应用程序,并尝试使用google帐户登录firebase,但出现了一个错误:

此环境不支持身份验证/操作。此应用程序运行的环境不支持此操作。“location.protocol”必须是http、https或chrome扩展,并且必须启用web存储

代码:


在react native中不支持使用弹出式登录。您需要使用第三方OAuth库获取OAuth ID令牌或访问令牌,然后使用Firebase登录:

const cred = firebase.auth.GoogleAuthProvider.credential(googleIdToken, googleAccessToken);
firebase.auth().signInWithCredential(cred)
  .then((result) => {
    // User signed in.
  })
  .catch((error) => {
    // Error occurred.
  });

在react native中不支持使用弹出式登录。您需要使用第三方OAuth库获取OAuth ID令牌或访问令牌,然后使用Firebase登录:

const cred = firebase.auth.GoogleAuthProvider.credential(googleIdToken, googleAccessToken);
firebase.auth().signInWithCredential(cred)
  .then((result) => {
    // User signed in.
  })
  .catch((error) => {
    // Error occurred.
  });

Firebase不支持在React本机环境中使用弹出窗口进行
登录

您可以在上查看受支持环境的完整列表


您还可以为React-Native提交扩展Firebase支持的功能请求。

Firebase不支持React-Native环境中的
signInWithPopup

您可以在上查看受支持环境的完整列表


您还可以提交功能请求,以获得对React-Native的扩展Firebase支持。

您是否使用正确的
Firebase
软件包?@Colin I导入Firebase就像“Firebase”一样,而不是像“React-Native Firebase”。我不知道为什么,但我的expo不支持原生firebase库。好了,你看。我建议只使用常规的
react native init
。@Colin,我会试试,谢谢。您使用的
firebase
软件包正确吗?@Colin我导入firebase就像“firebase”一样,而不像“react native firebase”。我不知道为什么,但我的expo不支持原生firebase库。好了,你看。我建议只使用常规的
react native init
@Colin,我会试试,谢谢。你能告诉我这里的googleIdToken和googleAccessToken是什么吗?这些是Google OAuth ID token和access token,你应该使用第三方OAuth库为react-native取回。你能告诉我这里的googleIdToken和googleAccessToken是什么吗?这些是Google OAuth ID token和access token您应该使用第三方OAuth库为react native获取的令牌。