React Native Firebase苹果auth错误:[auth / invalid-credential]提供的auth凭证格式错误或已过期

时间:2020-06-07 19:56:32

标签: javascript firebase react-native firebase-authentication

我正在尝试使用'@ invertase / react-native-apple-authentication'库在Firebase中实现苹果签名。

enter image description here

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

代码

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) {
        ...
    }
}

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

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