This sample app will showcase using Cognito Your User Pools with the AWS Mobile SDK for Android. The sample has been updated to support the features introduced in GA. The sample requires Android Studio and can run on Android SDK version 21 (Android 5) and above. Please follow the setup instructions to run this sample. This sample app includes demonstrates how to sign-up new users, confirm a user, sign-in as a user, see/change/delete user details, change a password, change a user’s MFA settings, verify user attributes and see users remembered devices.
Create Your user pool on the Cognito console
- Go to https://console.aws.amazon.com/cognito/ , the console contains step-by-step instructions to create the pool.
- Click on "Manage your User Pools" to open Your User Pools browser.
- Click on "Create a User Pool" to open "Create a user pool" page, here you can start creating a user pool.
- In "Create a user pool" page, give your pool a name and select "Review default" - this will create a user pool with default settings.
- Click on "Create pool" to create the new user pool.
- After creating a new pool, navigate to "App Integration" page (select "Apps Integration" from the navigation options on the left hand side) and click "Add app client..." from the "UI Customization" section.
- Click "Add an app client" and give a name to the app, e.g. "My Android App".
- Click "Create app client" to generate the app client id.
- Get the App client id and App client secret, if the secret was generated. To see the App client secret click on "Show Details".
- Get the "Pool Id" from the "Pool details" page (select "General settings" from the navigation options on the left hand side).
Download and import the AmazonCognitoYourUserPoolsDemo project into your Android Studio
- From the Welcome screen, click on "Import project".
- Browse to the AmazonCognitoYourUserPoolsDemo directory and click OK.
- Accept requests to add Gradle to the project.
- If the SDK reports missing Android SDK packages (such as Build Tools or the Android API package), import AWS SDK.
Modify the demo to run it on your user pool.
- Open the file AppHelper.java from the project files.
- Locate these four variables and add your pool details:
- userPoolId set this to your pool id.
- clientId set this to your app client id.
- clientSecret set this to your app client secret associated with the app client id. If your app client id does not have an associated client secret, set this variable to null, i.e. clientSecret = null.
- cognitoRegion set this to AWS Cognito Your User Pools region.
You are now ready to run this demo.