firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.73k stars 3.98k forks source link

[firebase_auth]: Error invalid_credential on iOS when attempting to call revokeTokenWithAuthorizationCode #16744

Open zakton5 opened 1 day ago

zakton5 commented 1 day ago

Is there an existing issue for this?

Which plugins are affected?

Auth

Which platforms are affected?

iOS

Description

I have set up Sign In with Apple according to the docs and have followed multiple tutorials to make sure I did everything right in my Apple Developer account and Firebase Settings. Pretty sure I'm good to go.

My app sign in with apple does work. The user gets signed up and can use my app normally. The problem is when allowing a user to delete their account. This is the error I get:

[firebase_auth/invalid-credential] Error getting access token from Apple. OAuth2 redirect uri is

The message leads me to think I didn't set something up right, but I have no idea where I would set an "OAuth2 redirect uri"

Expected result: Apple sign in is revoked and disappears from the Apps using Apple Sign In section in apple account settings.

Actual result: Above error message.

Reproducing the issue

Here is my code for both sign up and account deletion. According to the docs here, this is all I need: https://firebase.google.com/docs/auth/flutter/federated-auth#revoke-apple

    // Sign up
    final appleProvider = AppleAuthProvider()
      ..addScope('name')
      ..addScope('email');

    final firebaseCredential = await FirebaseAuth.instance.signInWithProvider(appleProvider);
      // Delete account
      final appleProvider = AppleAuthProvider();
      final res = await user.reauthenticateWithProvider(appleProvider);
      final authCode = res.additionalUserInfo?.authorizationCode;
      if (authCode == null) {
        throw Exception('Unable to get authorization code for apple account');
      }
      await FirebaseAuth.instance.revokeTokenWithAuthorizationCode(authCode);

Firebase Core version

3.8.0

Flutter Version

3.24.3

Relevant Log Output

No response

Flutter dependencies

Expand Flutter dependencies snippet
```yaml Replace this line with the contents of your `flutter pub deps -- --style=compact`. ```

Additional context and comments

No response

SelaseKay commented 1 day ago

Hi @zakton5, thanks for the report. I tested with your sample code and everything seems to work fine on my end. Could you provide a complete minimal code reproducing this issue?

zakton5 commented 19 hours ago

@SelaseKay Wouldn't that involve setting up a new flutter project, firebase project, apple app identifier, service id, etc. That's a lot of work that I don't have the time for. Even if I did that, how would you run the app without the means to connect to my apple account via Xcode?

Is there an example repository somewhere that I can cross reference to see if I did things right?