The Amplify Auth category provides an interface for authenticating a user.
Cognito lets you add user sign-up, sign-in, and access control to your web and mobile apps quickly and easily.
To start provisioning auth resources in the backend, go to your project directory and execute the command:
amplify add auth
$ Do you want to use the default authentication and security configuration?
`Default configuration`
$ How do you want users to be able to sign in?
`Username`
$ Do you want to configure advanced settings?
`No, I am done.`
amplify push
build.gradle
along with others you added above in Prerequisites and click “Sync Now” when prompted:dependencies {
implementation 'com.amplifyframework:aws-auth-cognito:1.17.4'
}
// Add this line, to include the Auth plugin.
Amplify.addPlugin(new AWSCognitoAuthPlugin());
Amplify.configure(getApplicationContext());
We can now check the current auth session.
For testing purposes, you can run this from your MainActivity’s onCreate
method.
Amplify.Auth.fetchAuthSession(
result -> Log.i("AmplifyQuickstart", result.toString()),
error -> Log.e("AmplifyQuickstart", error.toString())
);
Additional resources