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
accessKeyIdand thesecretAccessKeyof the user created - Adding an AWS profile
Setting up a React Native app
install exponpm install --g expo-cliexpo init aws-amplify-authentication-tutorialAdding AWS Amplify to a React Native application
cd C:\svn\aws-amplify-authentication-tutorial
amplify initnpm install aws-amplify aws-amplify-react-native @react-native-community/netinfoOpen 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 pushAt 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)
runexpo start
അഭിപ്രായങ്ങള്
ഒരു അഭിപ്രായം പോസ്റ്റ് ചെയ്യൂ