1

I'm trying to use credential_manager flutter package to implement 'Sign-in with Google' (for Android device only) and not able to get it to work successfully. I'm skipping the 'Password based credentials' and 'Passkey' parts for now and i'm not sure if that's causing the issue. The 'Usage' part of the documentation is not entirely clear, it says "Sign up using Google account and then you will be able to see the saved credentials in the app."

try{
    final GoogleIdTokenCredential credential = await credentialManager.saveGoogleCredential(
        useButtonFlow: false
      );

} on CredentialException catch (e) {
    // Handle the error
    print('Error saving Google credential: ${e.message}');
}
      

What does 'Sign up using google account..' mean? I assume it means the device is signed onto a google account outside my app beforehand, because nothing is mentioned about Sign-up in the docs. And I just call credentialManager.saveGoogleCredential() directly, but I'm getting a 'login failed' error in the console. The screen to select my google account appears, but nothing happens thereafter except the error. If i call

 await credentialManager.getCredentials(
      fetchOptions: credential_manager.FetchOptionsAndroid(googleCredential: true),
    );

I get 'No credentials found' error in console.

Although the docs on the native Android implementation of Credential Manager is more complete, I'm trying to avoid implementing native android/kotlin code as I have no experience with that. That could be a last resort as there is a pretty good YouTube guide done by someone.

I'm also using Firebase Auth for email/password login that I've already implemented, if anyone has advice on Credential Manager + Firebase Auth, that would be helpful too. Appreciate everyone's help, thanks!

Credential Manager flutter package

1 Answer 1

2

I got it working. Did you configure it ? For Sign In with Google, you need to update the "googleClientId" in the main.dart with the Web Client ID. You can refer to the Android Studio docs for this. I believe it should work when you follow the config part of the flutter plugin for Sign In for Google.

Sign up to request clarification or add additional context in comments.

2 Comments

I did follow all the configuration steps and update the googleClientId with the Web Client ID, but still couldn't get it to work. I had some confusion on the Android OAuth, was not sure which SHA1 to use (debug/release version and signing key certificate / upload key certificate), so I added all of them. I'm still trying.
usually you use debug during testing.. in the Google Console, you can only add one SHA1 for one client ID and u need to add one for Android, one for Web.. not sure what you mean by adding all. developer.android.com/identity/sign-in/credential-manager-siwg

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.