微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Firebase + React Native +使用Apple登录

如何解决Firebase + React Native +使用Apple登录

我正在尝试使用@invertase/react-native-apple-authentication软件包在Android上使用Apple登录https://github.com/invertase/react-native-apple-authentication/目前,我正在使用iOS,但是很难从Android的Firebase中恢复UID。我在控制台中看不到新添加用户,因为我认为我向Firebase发送了错误的信息?

我为此设置了与Android兼容的必要要求,包括在Apple开发者网站上为Web制作了serviceID,并在firebase控制台中启用了OAuth。并将所有ID和私钥分别放在相应的字段中。

  /**
   *
   * @returns {Promise<void>}
   */
  const handleAppleLogin = async () => {
    // Generate secure,random values for state and nonce
    const rawNonce = uuid();
    const state = uuid();

    try {
      appleAuthAndroid.configure({
        clientId: 'LEFT_OUT_MATCHES_THE_APPLE_CLIENT_ID',redirectUri: 'LEFT_OUT_MATCHES_THE_APPLE_REDIRECT',scope: appleAuthAndroid.Scope.ALL,responseType: appleAuthAndroid.ResponseType.ALL,nonce: rawNonce,state,});

      const { id_token } = await appleAuthAndroid.signIn();

      const androidCredential = firebase.auth.OAuthProvider.credential(
        id_token,rawNonce,);

      const userCredential = await firebase
        .auth()
        .signInWithCustomToken(androidCredential.token);

      // ALSO TRIED .signInWithCredential(androidCredential);

      console.log('userCredential',userCredential);

      ...

遵循文档:https://github.com/invertase/react-native-apple-authentication/blob/master/example/app.android.js

我可以获得id_token和appleAuthAndroid.signIn();附带的所有内容,并且可以获得androidCredential对象上所有内容的响应,包括providerId'secret ,and token {{ 1}} userCredential`我遇到了问题。

我没有从Firebase找回UID。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。