Google sign-in 

Google authentication will use the instance of the GoogleSigninOptions class and also it needs a googleApiClient object. Using a builder pattern, we will construct the following code snippet that will be passed to googleApiClient later:

GoogleSignInOptions signInOptions = new
GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.requestProfile()
.build();

This fabricates a GoogleSignInOptions instance by utilizing the default arrangement for a Google Sign-in operation. The instance is arranged to ask for the client's Google account ID token, email address, and profile data. The ID token will be utilized later in return for Firebase authentication credentials.

Now, using the GoogleSignInOption that has been created, we can create the GoogleApiClient class like this: 

GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, signInOptions)
.build();

We need to use the getSignInIntent method for the sign-in, and on successful sign-in, it returns a  GoogleSignInResult object:

Auth.GoogleSignInApi.getSignInIntent(googleApiClient);

Using the following method, we can register Google data with Firebase:

private void GoogleFirebase(GoogleSignInAccount googleSignin) {
AuthCredential credential = GoogleAuthProvider.getCredential(
googleSignin.getIdToken(), null);
firebaseAuth.signInWithCredential(credential)
.addOnCompleteListener(this,
new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (!task.isSuccessful()) {
Toast.makeText(MainActivity.this, "Firebase authentication failed.", Toast.LENGTH_SHORT).show();
}
}
});
}

To sign out, we can use the signOut method of the GoogleSignInApi object:

public void signOut(View view) {
FirebaseAuth.signOut();
Auth.GoogleSignInApi.signOut(googleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
}
});
}

Most of the configuration that we did using FirebaseUI will remain the same; for example, adding an SHA-1 fingerprint is a similar process.