How to save google login integration Firebase

I know how to save basic information into my Firebase database but I have no idea how to save google login integration into my Firebase database Can someone explain me?

this is the code I tried for saving info

DocumentReference documentReference = fStore.collection("users").document(personId);
            Map<String,Object> user = new HashMap<>();
            user.put("fName",personName);
            user.put("email",personEmail);

            documentReference.set(user).addOnSuccessListener(new OnSuccessListener<Void>() {
                @Override
                public void onSuccess(Void aVoid) {
                    Log.d(TAG, "onSuccess: user Profile is created for "+ personId);
                }
            }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Log.d(TAG, "onFailure: " + e.toString());
                }
            });
        }
    } catch (ApiException e) {

    }

Answer

This code for Google you have to register your app in google console for google sign up. After register enable GMAIL API. At the end you will get a special key from console which you have to add here .requestIdToken(getString(R.string.server_client_id))

    GoogleSignInClient mGoogleSignInClient;
    
     
    
      GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestIdToken(getString(R.string.server_client_id))
                    .requestEmail()
                    .build();
    
            mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
 // call this on button call.
 Intent signInIntent = mGoogleSignInClient.getSignInIntent();
                    startActivityForResult(signInIntent, 1);

    @Override
        protected void onActivityResult(int requestCode, int responseCode,
                                        Intent data) {
            super.onActivityResult(requestCode, responseCode, data);
            callbackManager.onActivityResult(requestCode, responseCode, data);
            if (requestCode == 1) {
                Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
                handleSignInResult(task);
            }
        }

 private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
        try {
            GoogleSignInAccount account = completedTask.getResult(ApiException.class);
            if (account != null) {
                String personName = account.getDisplayName();
                String personEmail = account.getEmail();
                String personId = account.getId();
            }
        } catch (ApiException e) {
             
        }
    }