I want to log in using google, but I still get task.isSuccessful = false. I cannot go through this condition
I will also add that on firebase there is added SHA-1 and updated JSON file. Any suggestions on how to solve this? :)
My code
class GoogleAuth : StartActivity() {
private lateinit var firebaseAuth: FirebaseAuth
private lateinit var googleSignInClient: GoogleSignInClient
private companion object {
private const val RC_SIGN_IN = 100
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.web_client_token_id))
.requestEmail()
.build()
googleSignInClient = GoogleSignIn.getClient(this, gso)
googleSignIn()
}
/**Google SignIn*/
private fun googleSignIn() {
val signInIntent = googleSignInClient.signInIntent
startActivityForResult(signInIntent, RC_SIGN_IN)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == RC_SIGN_IN) {
val task = GoogleSignIn.getSignedInAccountFromIntent(data)
val exception = task.exception
if (task.isSuccessful) {
try {
// Google Sign In was successful, authenticate with Firebase
val account = task.getResult(ApiException::class.java)!!
Log.d("GoogleSignInActivity", "firebaseAuthWithGoogle:" + account.id)
firebaseAuthWithGoogle(account.idToken!!)
} catch (e: ApiException) {
// Google Sign In failed, update UI appropriately
Log.w("GoogleSignInActivity", "Google sign in failed", e)
}
} else {
Log.w("GoogleSignInActivity", exception.toString())
}
}
}
}