Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 444
Vinay Nagaraj Avatar asked Dec 15 '15 07:12

Vinay Nagaraj


2 Answers

To avoid java.lang.IllegalArgumentException: Must specify an idToken or an accessToken, use

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

[find googleClientId - Here][1]

like image 125
Hoa Nguyen Avatar answered Oct 19 '22 23:10

Hoa Nguyen


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. :-)

like image 26
Frank van Puffelen Avatar answered Oct 19 '22 22:10

Frank van Puffelen