Authenticating your Android app users: an introduction to AWS Amplify authentication

  • by
Image for post

So you’re developing an Android App and you want to manage your users.

Image for post
You can use your own forms

You want to control access to certain of your app functions and your users will need secure access to your cloud back end. Oh, and you also need to give certain privileges to guest users.

This can be a challenge, taking hours and hundreds of lines of code but it does not have to be. Amazon has a set of open-source client libraries that you can use in your Android apps to not only make user management quick and easy but it also gives you the power of leveraging the AWS cloud.

Using Amplify in your Android apps will reduce the amount of code, cut development time considerably, and boost the power of your apps by giving them access to cloud resources such as lambda functions, Api’s, databases and user management.

If you want to control user access to your app and cloud back end, then you need the Amplify authentication library. The authentication library acts as an interface between your Android app and the back end Amazon User pool and Identity pool. The user pool contains your user information while the identity pool issues temporary credentials to logged in or authenticated users as well as to guest users.

You can also enable 3rd party identity providers like Google, Facebook and Amazon which your users can use to log in and get credentials to access your back end resources.

Image for post
You can also use the pre-built Web Ui forms

Amplify even has pre-built registration and login forms that will handle the complete authentication flow for you. So there is no need for you to build and manage any forms.

The beauty of using the authentication library is that it is quick and easy to install and use. During installation, it builds a complete back end for you, including IAM roles, a Cognito user pool and an identity pool.

Image for post
It’s easy installing Amplify authentication using the CLI in a terminal

Once installed, you only have to call the necessary functions and Amplify takes care of everything for you, seamlessly.

The installation is, as mentioned, very easy. Simply open up a terminal and install the Amplify Command Line Interface or CLI. Then install the authentication library by following the screen prompts. Most of the prompts are default settings which you simply accept.

The authentication library is essential if you’re going to use any of the other Amplify libraries such as the Api library for both GraphQl and REST requests, Analytics, DynamoDb DataStore, Predictions and S3 storage. The authentication library takes care of signing requests to the back end for you, in the background.

Here’s a quick demo of a basic authentication flow using the AWS Amplify authentication library in an Android