How to validate firebase login with facebook

I have the following code executing when a user logs in to facebook:

FB.Event.subscribe('auth.authResponseChange', checkLoginState);

Here is the code to analayse:

    function checkLoginState(response) {
        if (response.authResponse) {
            // User is signed-in Facebook.
            const unsubscribe = onAuthStateChanged(auth, (firebaseUser) => {
                unsubscribe();
                // Check if we are already signed-in Firebase with the correct user.
                if (!isUserEqual(response.authResponse, firebaseUser)) {
                    // Build Firebase credential with the Facebook auth token.
                    const credential = FacebookAuthProvider.credential(
                        response.authResponse.accessToken);

                    // Sign in with the credential from the Facebook user.
                    let x = signInWithCredential(auth, credential)
                        .catch((error) => {
                            // Handle Errors here.
                            const errorCode = error.code;
                            const errorMessage = error.message;
                            // The email of the user's account used.
                            const email = error.customData.email;
                            // The AuthCredential type that was used.
                            const credential = FacebookAuthProvider.credentialFromError(error);

                            alert("Login failed. Please try again.");
                        });

                    x.then((userCredential) => {
                        // Signed in
                        const user = userCredential.user;
                        // login(response.authResponse.accessToken, firebasetoken???);
                    });

                } else {
                    // User is already signed-in Firebase with the correct user.
                    console.log(response);
                    // login(response.authResponse.accessToken, firebasetoken???);
                }
            });
        } else {
            // User is signed-out of Facebook.
            signOut(auth);
        }
    }

I’m unsure how to pass the FIREBASE login token to verify in the backend (with kreait):

        $auth = (new Factory)
            ->withServiceAccount($_ENV["PATH"].$_ENV['config']['storage']['firebase']['firebase']['file'] ?? 'firebase-service-account.json')
            ->createAuth();

        // verify token
        $verifiedIdToken = $auth->verifyIdToken($token);
        $uid = $verifiedIdToken->getClaim('sub'); // throws an InvalidToken when invalid

Kreait docs:
https://github.com/kreait/firebase-php

Any help is appreciated.