0

I want to incorporate Google sign-in in my app (not with the Firebase UI as seen here), but manually so to speak, as seen here

In the image I provided below there's a part that says:

You must pass your server's client ID to the requestIdToken method. To find the OAuth 2.0 client ID:

a. Open the Credentials page in the API Console.

b. The Web application type client ID is your backend server's OAuth 2.0 client ID.

I did some research and found this which was very informative but the clarification I am seeking wasn't quite there.

What I wanted to know is:

If I am only using Firebase as my backend and no physical server of my own do I need to do the step that says

You must pass your server's client ID to the requestIdToken method...

Or am I fine with just leaving this line of code: .requestIdToken(getString(R.string.default_web_client_id)) since I am only using Firebase and no physical servers of my own?

I just need some clarification before I continue with implementing Google sign-in this way and not with the FirebaseUI.

Firebase Google Sign-In Authentication

Equivocal
  • 912
  • 2
  • 14
  • 27

1 Answers1

1

According to FirebaseUI 0.3, the following lines were needed to build the Google sign-in options:

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
    .requestIdToken(googleClientId)
    .requestEmail()
    .build();

In which googleClientId is the user Id as described in the Firebase official documentation for Google authentication. The most important thing to note here is that you need to create a web application, despite the fact that you're building an Android app.

But, once FirebaseUI 0.3.1 was released, we see that we don't need to specify an id token anymore. The following lines of code, are all you need:

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

Less configuration to worry about.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • Ok, but I'm not using FirebaseUI I'm using their guidelines to implement Google sign-in manually using Firebase SDK on their official website, not the FirebaseUI on gitHub. So if I'm doing it via their official website am I good to go with just using the default web client id string? – Equivocal Dec 19 '17 at 14:21
  • 1
    Go with the official doc. Yes, that's correct, use only the `R.string.default_web_client_id`. – Alex Mamo Dec 19 '17 at 14:26