Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide given and family name during Apple native sign in #105

Closed
domhel opened this issue Jul 7, 2024 · 4 comments
Closed

Provide given and family name during Apple native sign in #105

domhel opened this issue Jul 7, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@domhel
Copy link
Contributor

domhel commented Jul 7, 2024

Feature request

Is your feature request related to a problem? Please describe.

When signing up with Apple natively, the name is not propagated to supabase and not returned by the _nativeAppleSignIn() method.

However, Apple has strict rules: when a user signs up natively with their name, the app must not ask for their name again, because the user has already given us their name.

Describe the solution you'd like

Provide a callback during _nativeAppleSignIn() that takes

    final credential = await SignInWithApple.getAppleIDCredential(
      scopes: [
        AppleIDAuthorizationScopes.email,
        AppleIDAuthorizationScopes.fullName,
      ],
      nonce: hashedNonce,
    );

    // My addition here:
    onAppleFullNameReceived(credential.givenName, credential.familyName);

    // continue with supa auth

Describe alternatives you've considered

Best way would be to fix supabase so they already include the names in the raw metadata like with Google OAuth. But I was not able to dig into it.

Additional context

I have created a solution that works for me in a branch, will create a PR.

@domhel domhel added the enhancement New feature or request label Jul 7, 2024
domhel added a commit to domhel/flutter-auth-ui that referenced this issue Jul 7, 2024
@dshukertjr
Copy link
Member

When a user signs in using Apple for the first time for the app, Apple will provide the full name and email address if the user approves it. The full name and email address will be available in the raw user metadata the same way as Google login, and you can use triggers to store them in any table that you would like.

If you are not seeing the full name and email address after completing the Apple sign in, it means that the user has signed-in on the same app before.

@domhel
Copy link
Contributor Author

domhel commented Jul 8, 2024

I don't see this happening, even in production. I even added analytics logs to my app whenever someone signs up using apple, and the metadata have never been there. There are also open issues on supabase. The only thing that is working is this workaround that others have proposed and that I am using now and have started in my fork.

@dshukertjr
Copy link
Member

Could you link the issues that you have found discussing this topic? If it's an existing bug, we should fix it the proper way. The Supabase auth server should be storing that information on the user's metadata.

@domhel
Copy link
Contributor Author

domhel commented Jul 8, 2024

Here the references:

However, I've seen this comment from you:

@takuya-ohmuro Currently, Supabase does request for email and full name scope when performing Apple sign in. You can retrieve the full name like this:

final response = await supabase.auth.signInWithApple();
print(response.user?.userMetadata?['full_name']);

But the method signInWithApple does not exist anymore. Instead, the native apple sign in is used and then the signInWithIdToken.
I don't even know why it should work, because the native apple sign in returns the full name in the credentials, but these credentials are only used for the identity token and the name is thrown away. Maybe I don't see the hidden magic here. Also, I don't know how the old function worked, maybe you know more.

Another option that I have not tested yet is at the _nativeAppleSignIn() call, the return type is ignored. Per haps that auth response holds the metadata and we would then have to call supabase.auth.updateUser with that metadata, but would still not be a pretty way to handle this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants