Sunday, June 9, 2019

AWS Amplify and Cognito Basic Integration

Recently I have been working with Amplify and Cognito. I found some of the docs a little lacking so I figured I should write up some instructions for anyone else struggling to get it all configured right. The best AWS reference page I found was this and obviously you should have started here. What I found is that there are some extra things that you need to do in your Cognito User Pool to get everything working right. My goal here is to clarify how to get the integration basics setup so you can move forward with your development. Your final setup may vary based on how many apps, web pages and backend services you need to support.

So I assume you have added auth and pushed it to your backend already. After this if you want to use the built in web UI you need to setup the domain prefix. It needs to be unique within the AWS region so you may need to get creative. You could also use custom domain as well of course.
Configuring domain prefix or custom domain

Next you want to make sure your app clients are setup correctly. Amplify should have made you couple of app clients already one for web and one for apps. Take a look at the below images for the correct configuration. I made these with requiring unique email only. If you are using phone as well, just check that off on both. 

For web the callback and signout URLs should be something valid in your domain, if you are doing mostly local dev you can put in the localhost entries as shown below, they don't need to be valid initially to get basic things working.


Web client configuration

For the mobile app(s) you need to put in the app URI(s) instead. 
App client configuration
Now it is time to test your setup with the web interface. Construct the URL with the below template:



Replace the [PREFIX] with your chosen one and [CLIENT_ID] with the web client id after that you should get a login screen like this:


You should be able to sign up and login with this interface. Congratulations you have a working Cognito Integration.

AWS Amplify and Cognito Basic Integration

Recently I have been working with  Amplify  and  Cognito . I found some of the docs a little lacking so I figured I should write up some ins...