Im getting com.google.android.gms.common.api.ApiException: 12500 and can't figure it out.
This issue is only with the google login, it works with the created accounts still.
Ive tried SHA1, SHA256, the google play service is up to date, tried different accounts, phones and emulators. Ive also updated the json file.
LoginActivity checks the email and password then checks if the server authorizes the details
public class LoginActivity extends AppCompatActivity{
private EditText userName, pass;
private FirebaseAuth mAuth;
Dialog settingsDialog;
private GoogleSignInClient mGoogleSignInClient;
private SignInButton signInButton;
@Override
public void onCreate(Bundle bundle){
super.onCreate(bundle);
setContentView(R.layout.activity_login);
userName = (EditText) findViewById(R.id.login_username_text);
pass = (EditText) findViewById(R.id.login_password_text);
mAuth = FirebaseAuth.getInstance();
// Configure Google Sign In
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
signInButton = (SignInButton) findViewById(R.id.google_signin_button);
signInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
startActivityForResult(signInIntent, 101);
}
});
}
public void loginButtonClicked(View view){
settingsDialog = new Dialog(this);
if(!userName.getText().toString().isEmpty() && !pass.getText().toString().isEmpty()) {
mAuth.signInWithEmailAndPassword(userName.getText().toString(), pass.getText().toString())
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
FirebaseUser user = mAuth.getCurrentUser();
settingsDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
settingsDialog.setContentView(getLayoutInflater().inflate(R.layout.image_layout, null));
settingsDialog.show();
loginSucessfull(user);
} else {
//Handle invalid password or email
Toast toast = Toast.makeText(getApplicationContext(),R.string.invalid_name, Toast.LENGTH_SHORT);
toast.show();
}
}
});
}
}
private void loginSucessfull(FirebaseUser user){
Intent myIntent = new Intent(LoginActivity.this, TopicRoomActivity.class);
myIntent.putExtra("mauth", user);
LoginActivity.this.startActivity(myIntent);
finish();
}
public void createButtonClicked(View view){
Intent myIntent = new Intent(LoginActivity.this, CreateAccountActivity.class);
LoginActivity.this.startActivity(myIntent);
}
@Override
public void onStop(){
super.onStop();
if(settingsDialog != null)
settingsDialog.dismiss();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == 101) {
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
try {
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = task.getResult(ApiException.class);
firebaseAuthWithGoogle(account);
} catch (ApiException e) {
Log.w("*******","Google sign in failed", e);
}
}
}
private void firebaseAuthWithGoogle(GoogleSignInAccount account){
AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null);
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.w("******************","Logining in");
FirebaseUser user = mAuth.getCurrentUser();
loginSucessfull(user);
} else {
}
// ...
}
});
}
}
Exception as below :
com.google.android.gms.common.api.ApiException: 12500: at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source:4) at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source:8) at com.juddit.juddit_main.LoginActivity.onActivityResult(LoginActivity.java:122) at android.app.Activity.dispatchActivityResult(Activity.java:7454) at android.app.ActivityThread.deliverResults(ActivityThread.java:4353) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4402) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)