hi all, there’s a chance this is :not-kotlin-but-kotlin-colored: but I’m having an issue implementi...
n
hi all, there’s a chance this is not kotlin but kotlin colored but I’m having an issue implementing the “Integrate Credential Manager with Sign in with Google” flow in my app (code in reply). When I call
getCredential()
I immediately get a
NoCredentialException
with no bottom sheet sliding up or any other UI items. The identity-samples repo contains the
CredentialManager
project--I can insert the code snippet in
onCreate()
and everything works as expected--the bottom sheet slides up and exposes a number of accounts available on my system and I can continue the sign-in flow. That project uses xml views, though, and not compose. I tried to insert the same get credential code in the Now In Android app, which does use compose, and I get the same
NoCredentialException
. Is there a compose feature I need to enable to get this to work? I’ll continue trying to put together a trivial example, but if you’re aware of one sitting around, I’d really appreciate it. Am I barking up the wrong tree?
Copy code
val cm = androidx.credentials.CredentialManager.create(this)
        lifecycleScope.launch {
            val getPublicKeyCredentialOption =
                GetGoogleIdOption.Builder()
                    .setFilterByAuthorizedAccounts(false)
                    .setServerClientId("hello")
                    .build()
            try {
                cm.getCredential(
                    context = this@NiaCatalogActivity,
                    request = androidx.credentials.GetCredentialRequest(
                        listOf(
                            getPublicKeyCredentialOption,
                            // getPasswordOption
                        )
                    )
                )
            } catch (e: Exception) {
                Log.e("Auth", "getCredential failed with exception: $e")
            }
        }
e
this is neither Compose- nor Kotlin-related, but try having a FragmentActivity or AppCompatActivity host instead of just a ComponentActivity
n
will do. thank you.
t
@Nick hey I found this thread by googling for this error. did you ever figure out a solution?
n
hey @timwie --sorry about that, I should’ve posted it here. Turns out it was an issue with my firebase configuration--there are a couple ways to specify your app’s SHA fingerprint: SHA-1 and SHA-256--I only had the SHA-256 set. If you implement the (deprecated) One Tap UI, the exception/result is
10: Developer console is not set up correctly.
(instead of
NoCredentialsAvailable
). TL;DR: the SHA-256 certificate fingerprint is insufficient to allow credential manager to work--it needs to have the SHA-1 in there as well. Hope this helps, and good luck!