Search code examples
iosswiftapple-sign-inasauthorizationcontroller

How to create an account using "Sign in with Apple"


My dev team is trying to add Sign In With Apple functionality to an existing system that uses email/password for account creation / logging in. I'm not sure I understand the flow for Sign in with Apple, using this starting point.

The sample code has code for dealing with a ASPasswordCredential but it's never provided in a callback.

It also tells the dev where to create a user account on their own backend, but our backend has a simple registration endpoint that requires email address, user's full name, and of course a password.

Have I not understood something here? Is the sign in with apple flow supposed to be providing me with a password that I use to create a user, or am I supposed to create a user in a different way? Will this code only work if I've gone through the steps of setting up Password Autofill (i.e. AASA file, setting up associated domains, etc.) ?

I didn't provide code here as I assume there are others that are going through these same steps given the link above and my question is high-level. (I can update my answer to add more context instead of suffering the downvotes... just let me know, thanks!)


Solution

  • This section of the page you pointed to tells you what to do. You are provided with unique identifying information for the user who has signed up. Your job is to store that so that you can recognize this user the next time they sign in.

    but our backend has a simple registration endpoint that requires email address, user's full name, and of course a password

    You need to change that. The back end cannot require this, because for a user who signs up with Apple, you won't get it. That is the entire point of Sign Up With Apple: it keeps that information out of your hands.

    In other words, your entire flow needs to adapt to having two kinds of user: those who sign up with you and those who sign up with Apple. Certain features of your flow may have to be denied to users who signed up with Apple; for example, if your app has a change password feature, you mustn't show that to a sign-up-with-Apple user, because you have no password for this user.