Integrate AWS Amplify Cognito in Android
Posted By : Mohd Anas | 14-Dec-2020
In this blog, I am briefly describing to you how to integrate the Amplify Cognito User pool in android for User Management.
To use Amplify Framework, We need to add some configurations in our system. these are the steps to add the Amplify framework in android.
To install the Node Js, Click the below link and select the Operating System Whatever you are using to Download Node Js.
https://nodejs.org/en/download/
Install CLI
First, we need to install Amplify CLI in our system. To install the CLI we need to run the above command in the Command prompt in System Root Directory.
Note: While setting up the Amplify you need to have an AWS Developers Console Account or you can create it during setup.
Create a new project or you can also use an existing one.
Add the line mavenCentral() within the repositories block in the build script and allprojects blocks
In the build.gradle app file adds the following dependencies and Java compile options to Java8.
Also Read: How To Deal With The AWS Abuse Report
then run the following command in the project root directory to initialize the amplify in the project then do the basic setup.
After doing the setup, Add the following dependency in the Gradle file to add Authentication in the application.
Then run the "amplify add auth" command to set up the Authentication with CLI.
After that, run the command "amplify push" to push all the changes in the backend AWS Console. This command creates the user pool on the AWS Console to save all the users.
Initialize Amplify Auth
Add the Auth plugin along with any other plugins you added per the instructions in the Prerequisites section:
Also Read: Integrating AWS Elastic Transcoder With NodeJS Application
Register a user
The default CLI flow as mentioned in the getting started guide requires a username, password and a valid email id as parameters to register a user. Invoke the following api to initiate a sign-up flow.
The next step in the signup flow is to confirm the user. A confirmation code will be sent to the email id provided during sign up. Enter the confirmation code received via email in the confirmSignUp call.
You will know the sign-up flow is complete if you see the following in your console window:
Confirm signUp succeeded
Sign in a user
Implement a UI to get the username and password from the user. After the user enters the username and password you can start the sign in flow by calling the following method:
You will know the sign in flow is complete if you see the following in your console window:
Sign in succeeded
You have complete the registration and authentication of the user with the username and password in Amplify. The Authentication category supports other mechanisms for authentication such as web UI based sign in, sign in using other providers, etc that you can explore in the other sections.
Avail Our AWS Development Services To Strengthen Your Enterprise Processes
We are a 360-degree cloud app development company that provides end-to-end AWS application development services for varied business needs. Our development team is experienced in using and implementing a variety of Amazon Web Services such as AWS Lambda, CloudFront, ElasticSearch, Amazon S3, Amazon EC2, Kinesis, Amazon ECS, and more. For project-related queries, reach us out at [email protected]m.
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Mohd Anas
Anas is working as an Android Developer in Oodles Technologies. He is hard working, Self Motivated and dedicated towards his work. He is also passionate about learning new technologies related to our fields.