Open Nikoloutsos opened 4 years ago
I have the same issue for 1 week. Everything was working before. It occurs from Android 8
Update 1: The issue still persist on one of our devices (Huawei P-smart @ Android 9). Update 2: Within the phone's user account I removed our app from accessing google drive data. After this the login flow worked fine again. This is a test account which we use on many devices and login / logout all the time. Possibly something went corrupt; or mid development we changed permissions such that they are no longer compatible with the originally acquired permissions. Alas it hints at an error on Google Play's end.
My original response is below, for posterity. I doubt it's relevant for anyone. Although it might be entirely unrelated to your issue: for my implementation the '8' status code was returned when you try to login when you are already logged in. In our use-case this was caused due to poor a implementation on our end where "logout" didn't actually log the user out.
The final solution uses a login flow as follows:
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(context);
GoogleSignInOptions signInOptions = GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN;
if ( GoogleSignIn.hasPermissions(account, signInOptions.getScopeArray())) {
// use 'account ' as you see fit.
} else {
// Trigger a silent login, followed by interactive if silent fails.
}
I'll make a point to update this post in case there's another mitigating issue.
I hope this helps anyone else, as this github issue is the first hit on my favourite search engine - with no other sensible search results.
-_-, lol
Facing the same error, do we have any update about this ?
Presumably not, if you still have the issue. Sorry. Check my "Update 2:" above to see if that helps you.
I suspect this crash use-case only happens for developers.
Getting a similar error when trying to sign in (see also on stackoverflow.
private fun signIn() {
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build()
val googleSignInClient = GoogleSignIn.getClient(this, gso)
val signInIntent = googleSignInClient.signInIntent
val task = GoogleSignIn.getSignedInAccountFromIntent(signInIntent)
try {
val auth = Firebase.auth
// Authenticate with Firebase using Google credentials
val account = task.getResult(ApiException::class.java)
val credential = GoogleAuthProvider.getCredential(account?.idToken, null)
auth.signInWithCredential(credential)
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// User is logged in, obtain JWT token and return to calling activity
val user = auth.currentUser
user?.getIdToken(true)?.addOnSuccessListener { result ->
val token = result.token
val resultIntent = Intent()
Timber.i(String.format("Logged in; Token %s", token))
resultIntent.putExtra("jwt_token", token)
setResult(Activity.RESULT_OK, resultIntent)
finish()
}
} else {
// Authentication failed, show error message
Toast.makeText(this, "Authentication failed.", Toast.LENGTH_SHORT).show()
}
}
} catch (e: ApiException) {
Timber.e(e);
// Google Sign-In failed, show error message
Toast.makeText(this, "Google sign-in failed.", Toast.LENGTH_SHORT).show()
}
}
Step 2: Describe your environment
Step 3: Describe the problem:
When using google log in it fails the first time. The exception is com.google.android.gms.common.api.ApiException: 8
Steps to reproduce:
Expected Results: