AWS Amplify auth

To use AWS amplify within your application, you must have the Amplify CLI. Open a terminal and paste the code below to install the Amplify CLI.


Install Amplify 

npm install -g @aws-amplify/cli 

After a successful installation of the Amplify CLI, run the following code to configure the CLI.

amplify configure
  • Specify an AWS region
  • Adding the accessKeyId and the secretAccessKey of the user created
  • Adding an AWS profile

Setting up a React Native app

install expo
npm install --g expo-cli
expo init aws-amplify-authentication-tutorial
choose default blank template.

Adding AWS Amplify to a React Native application

 cd C:\svn\aws-amplify-authentication-tutorial


amplify init
npm install aws-amplify aws-amplify-react-native @react-native-community/netinfo

Open the App.js file in your code editor and add the following lines of code after the last import statement:

import Amplify from 'aws-amplify';
import config from './aws-exports';
Amplify.configure({
  ...config,
  Analytics: {
    disabled: true,
  },
});

Adding authentication with Amazon Cognito

amplify add auth
  • Choose the default configurationamplify push

amplify push

At this point, we can integrate the authentication service in our application. The Amplify Framework provides built-in, customizable UI components that are easy to integrate, which helps streamline the process.

Go to your App.js and add the following line below the import statements:

import { withAuthenticator } from 'aws-amplify-react-native';

withAuthenticator is a higher-order component that automatically detects the authentication state of the application and updates the UI.

Change the default export at the end of App.js to the following:

export default withAuthenticator(App)
run
expo start










അഭിപ്രായങ്ങള്‍

ഈ ബ്ലോഗിൽ നിന്നുള്ള ജനപ്രിയ പോസ്റ്റുകള്‍‌

settingup aws amplify - terminal o/p

aws-amplify-auth command line backup