反应原生androidfirebase登录与苹果[错误:提供的身份验证凭据格式错误,已过期或当前不受支持。]

我正在使用 Apple 实现登录。我可以成功看到Apple登录页面。我输入正确的凭据。它应该能够根据 Apple 的返回值登录/注册 Firebase。

但是我收到了这个错误Error: The supplied auth credential is malformed, has expired or is not currently supported。Firebase 方面一定有问题吗?onPressAppleLogin逻辑上可以参考下面的函数。非常感谢!

我做了什么:

在 Firebase 中

  1. 启用Apple 登录提供程序的身份验证
  2. 我的服务 ID 是co.myexampleapp.signinwithapple
  3. 我的授权回调是https://my-example-app.firebaseapp.com/__/auth/handler

在 developer.apple.com 中

  1. 我创建了一个服务 ID co.myexampleapp.signinwithapple启用了该服务Sign In with Apple
  2. 我加my-example-app.firebaseapp.com为域和https://my-example-app.firebaseapp.com/__/auth/handlerReturn URLs

我的 React Native 源代码

import { appleAuthAndroid } from '@invertase/react-native-apple-authentication';
import firebase from 'react-native-firebase'

getRandomString = (length: any) => {
    let randomChars =
        'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
    let result = ''
    for (let i = 0; i < length; i++) {
        result += randomChars.charAt(Math.floor(Math.random() * randomChars.length))
    }
    return result
}

onPressAppleLogin = async () => {
    const rawNonce = this.getRandomString(20);
    const state = this.getRandomString(20)

    appleAuthAndroid.configure({
        clientId: 'co.myexampleapp.signinwithapple',
        redirectUri: 'https://my-example-app.firebaseapp.com/__/auth/handler',
        responseType: appleAuthAndroid.ResponseType.ALL,
        scope: appleAuthAndroid.Scope.ALL,
        nonce: rawNonce,
        state,
    });

    const response = await appleAuthAndroid.signIn();

    const appleCredential = await firebase.auth.AppleAuthProvider.credential(response.id_token, rawNonce)

    const appleUserCredential = await firebase.auth().signInWithCredential(appleCredential) // error happens here!
}

以上是反应原生androidfirebase登录与苹果[错误:提供的身份验证凭据格式错误,已过期或当前不受支持。]的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>