【问题标题】:React Native Firebase apple auth Error: [auth/invalid-credential] The supplied auth credential is malformed or has expiredReact Native Firebase 苹果身份验证错误:[auth/invalid-credential] 提供的身份验证凭据格式错误或已过期
【发布时间】:2020-09-26 18:09:59
【问题描述】:

我正在尝试使用“@invertase/react-native-apple-authentication”库通过 firebase 实现苹果签名。

执行 signInWithCredential 方法时出现问题。 Firebase 返回错误:错误:[auth/invalid-credential] 提供的身份验证凭据格式错误或已过期

代码

export async function loginWithApple() {
    // Start the sign-in request
    try {
        console.log('TRY');
        const appleAuthRequestResponse = await appleAuth.performRequest({
            requestedOperation: AppleAuthRequestOperation.LOGIN,
            requestedScopes: [
                AppleAuthRequestScope.EMAIL,
                AppleAuthRequestScope.FULL_NAME,
            ],
        });

        console.log('CHECK TOKEN');
        // Ensure Apple returned a user identityToken
        if (!appleAuthRequestResponse.identityToken) {
            throw 'Apple Sign-In failed - no identify token returned';
        }

        // Create a Firebase credential from the response
        const {
            nonce,
            identityToken,
        } = appleAuthRequestResponse;

        if (identityToken) {
            console.log(nonce, identityToken);

            // Sign the user in with the credential
            const appleCredential = auth.AppleAuthProvider.credential(
                identityToken,
                nonce,
            );
            auth()
                .signInWithCredential(appleCredential)
                .then((response) => console.log('loginWithApple', response))
                .catch((error) => console.log('222222', error));
            console.warn(
                `Firebase authenticated via Apple, UID: ${userCredential.user.uid}`,
            );
        } else {
            console.log('loginWithApple no token - failed sign-in');
        }
    } catch (error) {
        ...
    }
}

有人可以帮帮我吗?

【问题讨论】:

  • 嗨!希望你今天过得愉快。您能否指出我们需要在哪里正确输入服务 ID?谢谢

标签: javascript firebase react-native firebase-authentication


【解决方案1】:

所以...经过几天的调查,问题被发现了。在 Firebase 设置中,Services ID 是错误的。

【讨论】:

  • “服务 ID”是指客户端 ID?我有同样的问题。
猜你喜欢
  • 2019-11-22
  • 1970-01-01
  • 2020-05-07
  • 2019-12-17
  • 2021-07-08
  • 1970-01-01
  • 2019-07-22
  • 1970-01-01
  • 2022-11-11
相关资源
最近更新 更多