I'm trying to set up Google's One-Tap but with the new, all-in-one, Credential Manager.
However, after crawling through the (badly written) documentation, I've come to a halt. Upon "Signing in with Google", everything is fine until I get a "NoCredentialException: no credentials available", which makes sense.
But then... how do I create a credential?
Google provides examples to create credentials for both passwords and passkeys but I can't find any information on creating credentials for the "Sign In With Google" button (anywhere on the internet).
"The Sign In With Google Button is supported by Credential Manager with the newest Google ID helper library"
So, I use <CredentialManager>.createCredentialAsync()
because that's what Google used during the examples they provided (and explicitly told to do here).
However, Android's createCredentialAsync requires a CreateCredentialRequest
and there are only three types that it accepts: "CreatePasswordRequest", "CreatePublicKeyCredentialRequest" and "CreateCustomCredentialRequest".
This is where "Google's ID helper library" mentioned in the quote above is supposed to come in handy. The library has the classes GetGoogleIdOption and GetSignInWithGoogleOption which are both subclasses of GetCustomCredentialOption.
The question now is how am I supposed to get myself a CreateCustomCredentialRequest
class (or a subclass of it) for my <CredentialManager>.createCredentialAsync()
method.
Google's "newest ID helper library" doesn't provide:
- A subclass of CustomCredential & it's Builder for SignInWithGoogle (it does for GoogleIdToken)
- A ridiculously long
CreateSignInWithGoogleRequest
class (or aCreateGoogleIdRequest
class) that's a subclass of theCreateCustomCredentialRequest
class.
Therefore, since I'm stuck on how I'm supposed to get this CreateCustomCredentialRequest
, I'm not sure how I'm supposed to "Integrate Credential Manager with Sign in with Google" either.
Before I end, I want to mention one last thing. In the "Sign up with Google" section, it says:
If no results are returned after setting setFilterByAuthorizedAccounts to true while instantiating the GetGoogleIdOption request and passing it to GetCredentialsRequest, it indicates that there are no authorized accounts to sign in. At this point, you should set setFilterByAuthorizedAccounts(false) and call Sign up with Google.
This doesn't help me because:
- This only references
GetGoogleIdOption
and notGetSignInWithGoogleOption
. - There's no explanation on how to "call Sign up with Google".
Afterwards, it says:
Once you instantiate the Google sign-up request, launch the authentication flow similarly as mentioned in the Sign in with Google section.
Is there supposed to be a GetGoogleSignUpRequest
class?
Is there anything I'm missing? Did I make a stupid mistake somewhere? Any help on this would be great!
For extra context, I've provided the entirety of my code here: https://www.online-java.com/VjQw6cTKig