android - google single sign on not working when requesting a server token -


i have followed guide here: https://developers.google.com/identity/sign-in/android/start-integrating in code. have google services 3.0.0 , google play services 9.8.0. have following in oncreate of signin activity:

 googlesigninoptions gso = new googlesigninoptions.builder(googlesigninoptions.default_sign_in)                 .requestemail()                 .requestid()                 .requestprofile()                 .requestserverauthcode(getstring(r.string.gplus_client_key))                 .requestidtoken(getstring(r.string.gplus_client_key))                 .build();         mgoogleapiclient = new googleapiclient.builder(this)                 .enableautomanage(this, new googleapiclient.onconnectionfailedlistener() {                     @override                     public void onconnectionfailed(@nonnull connectionresult connectionresult) {                         system.out.println("test");                     }                 } /* onconnectionfailedlistener */)                 .addapi(auth.google_sign_in_api, gso)                 .build();         findviewbyid(r.id.google_sign_in_button).setonclicklistener(this); 

i got client ids area of api console: google client ids

i have following methods facilitate login:

 @override     public void onclick(view v) {         switch (v.getid()) {             case r.id.google_sign_in_button:                 signin();             break;         default:             break;     } }  private void signin() {     intent signinintent = auth.googlesigninapi.getsigninintent(mgoogleapiclient);     startactivityforresult(signinintent, rc_sign_in); }  public void onactivityresult(int requestcode, int resultcode, intent data) {     super.onactivityresult(requestcode, resultcode, data);     if (requestcode == rc_sign_in) {         googlesigninresult result = auth.googlesigninapi.getsigninresultfromintent(data);         handlesigninresult(result);         if (result.issuccess()) {             googlesigninaccount acct = result.getsigninaccount();             string idtoken = acct.getserverauthcode();             string email = acct.getemail();             progressdialog = new progressdialog(splashactivity.this);             progressdialog.setmessage("logging in...");             progressdialog.show();             _restservice.gplusloggin(splashactivity.this, _handler, email, idtoken);         } else {         }     } } 

the result code of onactivity result 0 instead of -1 represents success. when change googlesigninoptions

googlesigninoptions gso = new googlesigninoptions.builder(googlesigninoptions.default_sign_in)                 .requestemail()                 .requestid()                 .requestprofile()                 .build(); 

the result code returns success , can user information, not server key need authenticate login. seems point being wrong credentials, generated them through configuration file section of guide linked above, google-services.json file. know i'm missing make sign in work? have 3 other apps seemingly identical code sign in(except client id , google-services.json, generated individually), , work seamlessly. has had me stumped awhile, , appreciate insight issue.


Comments