Supporting Sign In With Apple In AWS Amplify

Irwansyah
3 min readMay 5, 2020

As per April 2020, Apple requires any new apps to support sign in with Apple Id. For people that is using AWS Cognito, fortunately they already support the Apple sign in (https://aws.amazon.com/blogs/security/how-to-set-up-sign-in-with-apple-for-amazon-cognito/). Unfortunately, for people that is using AWS Amplify, the sign in with Apple is still not supported. So how can we use sign in with Apple if our app already growing and we are using AWS Amplify?

Relax! Since AWS Amplify is using AWS Cognito in theory we just need to find out how AWS Amplify provide the authentication mechanism. We just need to open Amplify’s Auth source code. These are the source codes:

As you can see, from line 1474 and 1491 above, the Auth class will pass the string provider value to _oAuthHandler.oAuthSignIn() so we need to see what the method do:

From line 94 it is obvious, the method just build the url string. And these are the values of the provider string:

So that means, in theory, we can guess what will be the value for Apple sign in, let’s try by giving the value Apple :

Turned out, it is incorrect, since Cognito will give us this screen:

When we click the Continue with Apple button then it will show the correct sign in page. So what should we do then?

Ok! Let’s view the HTML source of that page:

We can see the identity_provider value is SignInWithApple so how about if we change our code with that value:

And it works:

--

--