Vinay Nagaraj Vinay Nagaraj - 1 month ago 12
Android Question

firebase serverClientId when building GoogleSignInOptions

I'm using the google sign-in workflow to get a GoogleSignInAccount object. I want to authenticate google users to my firebase app, which requires a token which can be requested using requestIdToken(String serverClientId) when building my google client api. I'm not sure what to put as my serverClientId?

Answer

This is what FirebaseUI 0.3 uses to build the sign-in options:

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

Where googleClientId is the client ID as described in the Firebase documentation for Google authentication. The most important thing to note there is that you need to create a web application, despite the fact that you're building an Android app.

But: you don't need to specify an id token anymore these days. In FirebaseUI 0.3.1, we'll be switching to this for building the sign-in options:

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

One less configuration value to worry about. :-)

Comments