Search code examples
flutterfirebase-authenticationapple-sign-in

"invalid_client" on Apple Sign-in for Flutter on Android and Web (using Firebase)


I've configured Sign in with Apple for my Flutter app using Firebase. Everything works correctly on iOS, but on both Android and the Web, it opens a popup that simply says "invalid_client" (see screenshot below). I'm fairly confident that everything is configured correctly with the private key and Service ID in the Firebase console.

Here's the Dart code I'm using with Flutter:

Future<void> signInWithApple() async {
  final provider = AppleAuthProvider();
  provider.addScope('email');

  late final UserCredential credentials;
  if(kIsWeb) {
    credentials = await FirebaseAuth.instance.signInWithPopup(provider);
  } else {
    credentials = await FirebaseAuth.instance.signInWithProvider(provider);
  }
}

Note that this is almost exactly identical to the sample code on the Firebase docs: https://firebase.google.com/docs/auth/flutter/federated-auth#apple

The result is visually the same on Android and Web. No errors are reported by any of the plugins or code involved.

Screenshot showing an Apple page with the error code invalid_client

If I need to contact support for specific help in this case, should I contact Firebase, Apple, or the Flutter plugin team for support? I'm not even sure what platform is in error (my guess is that it is Firebase or, more likely, the Flutter plugin that has implemented something incorrectly).


Solution

  • on iOS, Firebase use Apple native SDK, so the information you entered in Firebase console is not required.

    However, for non-apple device (android, web), you have to provide right information. Especially, I think you missed redirect url in Apple Developer Console.

    You have to add redirect url(https://YOUR_FIREBASE_PROJECT_ID.firebaseapp.com/__/auth/handler) in Apple Developer Console. (change YOUR_FIREBASE_PROJECT_ID to your firebase project id)