diff --git a/src/directory/directory.js b/src/directory/directory.js index 843587dddfc..b3baa70c32f 100644 --- a/src/directory/directory.js +++ b/src/directory/directory.js @@ -245,11 +245,6 @@ const directory = { route: '/lib/auth/getting-started', filters: ['android', 'flutter', 'ios', 'js', 'react-native'] }, - { - title: 'Create or re-use existing backend', - route: '/lib/auth/start', - filters: ['js', 'react-native'] - }, { title: 'Sign up, Sign in & Sign out', route: '/lib/auth/emailpassword', @@ -374,11 +369,6 @@ const directory = { title: 'Under the hood', route: '/lib/auth/overview', filters: ['android', 'ios', 'js', 'react-native'] - }, - { - title: 'Use existing Amazon Cognito resources', - route: '/lib/auth/existing-resources', - filters: ['android', 'flutter', 'ios'] } ] }, @@ -1159,11 +1149,6 @@ const directory = { title: 'Under the hood', route: '/lib-v1/auth/overview', filters: ['android', 'ios'] - }, - { - title: 'Use existing Amazon Cognito resources', - route: '/lib-v1/auth/existing-resources', - filters: ['android', 'ios'] } ] }, diff --git a/src/fragments/lib-v1/auth/existing-resources.mdx b/src/fragments/lib-v1/auth/existing-resources.mdx index ff6507ecf7f..004c9970b02 100644 --- a/src/fragments/lib-v1/auth/existing-resources.mdx +++ b/src/fragments/lib-v1/auth/existing-resources.mdx @@ -24,10 +24,10 @@ import nativeCommon0 from "/src/fragments/lib-v1/auth/native_common/existing_res - **Region**: AWS Region where the resources are provisioned (e.g. `us-east-1`) - **Auth**: - **Default**: - - **authenticationFlowType**: The authentication flow type, takes values `USER_SRP_AUTH`, `CUSTOM_AUTH`. Default is `USER_SRP_AUTH`. + - **authenticationFlowType**: The authentication flow type, takes values `USER_SRP_AUTH`, `CUSTOM_AUTH`, and `USER_PASSWORD_AUTH`. Default is `USER_SRP_AUTH`. - **OAuth**: Hosted UI Configuration (only include this if using the Hosted UI flow) - **Scopes:** Scopes should match the scopes enables in Cognito under "App client settings" Note that before you can add an AWS resource to your application, the application must have the Amplify libraries installed. If you need to perform this step, see [Install Amplify Libraries](/lib-v1/project-setup/create-application#n2-install-amplify-libraries). -If you are using a Cognito User Pool, without a Cognito Identity Pool, you can omit the **CredentialsProvider** section in the configuration. +If you are using a Cognito User Pool without a Cognito Identity Pool, you can omit the **CredentialsProvider** section in the configuration. diff --git a/src/fragments/lib-v1/auth/native_common/existing_resources/common.mdx b/src/fragments/lib-v1/auth/native_common/existing_resources/common.mdx index 40df3c114b5..3f99889e199 100644 --- a/src/fragments/lib-v1/auth/native_common/existing_resources/common.mdx +++ b/src/fragments/lib-v1/auth/native_common/existing_resources/common.mdx @@ -38,7 +38,7 @@ If you are not using the Amplify CLI, a Cognito User Pool and Identity Pool can "profile", "aws.cognito.signin.user.admin" ] - }, + } } } } diff --git a/src/fragments/lib-v1/auth/native_common/getting_started/common.mdx b/src/fragments/lib-v1/auth/native_common/getting_started/common.mdx index 2f8f379bfda..6d9b2162585 100644 --- a/src/fragments/lib-v1/auth/native_common/getting_started/common.mdx +++ b/src/fragments/lib-v1/auth/native_common/getting_started/common.mdx @@ -1,7 +1,8 @@ -The Amplify Auth category provides an interface for authenticating a user. Behind the scenes, it provides the necessary authorization to the other Amplify categories. It comes with default, built-in support for [Amazon Cognito](https://aws.amazon.com/cognito) User Pool and Identity Pool. The Amplify CLI helps you to create and configure the auth category with an authentication provider. +The Amplify Auth category provides an interface for authenticating a user. Behind the scenes, it provides the necessary authorization to the other Amplify categories. It comes with default, built-in support for [Amazon Cognito](https://aws.amazon.com/cognito) User Pool and Identity Pool. The Amplify CLI helps you create and configure the auth category with an authentication provider. ## Goal -To setup and configure your application with Amplify Auth and go through a simple api to check the current auth session + +To setup and configure your application with Amplify Auth and go through a simple api to check the current auth session. ## Prerequisites @@ -13,47 +14,31 @@ import android1 from "/src/fragments/lib-v1/auth/android/getting_started/10_preR -## Configure Auth Category - -To start provisioning auth resources in the backend, go to your project directory and **execute the command**: - -```bash -amplify add auth -``` +## Install Amplify Libraries -Enter the following when prompted: -```console -? 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.` -``` +import ios6 from "/src/fragments/lib-v1/auth/ios/getting_started/20_installLib.mdx"; -To push your changes to the cloud, **execute the command**: + -```bash -amplify push -``` +import android7 from "/src/fragments/lib-v1/auth/android/getting_started/20_installLib.mdx"; -import ios3 from "/src/fragments/lib-v1/auth/ios/getting_started/12_amplifyConfig.mdx"; + - +## Set Up Backend Resources -import android4 from "/src/fragments/lib-v1/auth/android/getting_started/12_amplifyConfig.mdx"; +To use Authentication with Amplify, you have the option to set up or import existing Amazon Cognito resources via the Amplify CLI or manually configure them in your application. - +import ios50 from "/src/fragments/lib/auth/ios/getting_started/50_configureBackend.mdx"; -## Install Amplify Libraries + -import ios6 from "/src/fragments/lib-v1/auth/ios/getting_started/20_installLib.mdx"; +import android50 from "/src/fragments/lib/auth/android/getting_started/50_configureBackend.mdx"; - + -import android7 from "/src/fragments/lib-v1/auth/android/getting_started/20_installLib.mdx"; +import flutter70 from "/src/fragments/lib/auth/flutter/getting_started/70_configureBackend.mdx"; - + ## Initialize Amplify Auth diff --git a/src/fragments/lib-v1/project-setup/android/use-existing-resources/use-existing-resources.mdx b/src/fragments/lib-v1/project-setup/android/use-existing-resources/use-existing-resources.mdx index be7e59be486..6aa6ae5b1e4 100644 --- a/src/fragments/lib-v1/project-setup/android/use-existing-resources/use-existing-resources.mdx +++ b/src/fragments/lib-v1/project-setup/android/use-existing-resources/use-existing-resources.mdx @@ -90,5 +90,5 @@ Select a category from the following list to view an example `amplifyconfigurati * See the [Analytics category](/lib-v1/analytics/existing-resources) to use existing AWS Pinpoint resources. * See the [API (GraphQL) category](/lib-v1/graphqlapi/existing-resources) to use existing AWS AppSync resources. * See the [API (REST) category](/lib-v1/restapi/existing-resources) to use existing Amazon API Gateway and AWS Lambda resources. -* See the [Authentication category](/lib-v1/auth/existing-resources) to use existing Amazon Cognito resources. +* See the [Authentication category](/lib-v1/auth/getting-started/q/platform/android/#prerequisites) to use existing Amazon Cognito resources. * See the [Storage category](/lib-v1/storage/existing-resources) to use existing Amazon S3 resources. diff --git a/src/fragments/lib/auth/android/getting_started/12_amplifyConfig.mdx b/src/fragments/lib/auth/android/getting_started/12_amplifyConfig.mdx index b54a4374faa..10fd28f3778 100644 --- a/src/fragments/lib/auth/android/getting_started/12_amplifyConfig.mdx +++ b/src/fragments/lib/auth/android/getting_started/12_amplifyConfig.mdx @@ -1 +1 @@ -Upon completion, `amplifyconfiguration.json` should be updated to reference provisioned backend auth resources. Note that these files should already be a part of your project if you followed the [Project setup walkthrough](/lib/project-setup/create-application). +Upon completion, `amplifyconfiguration.json` should be updated to reference provisioned backend auth resources. Note that these files should already be a part of your project if you followed the [project setup walkthrough](/lib/project-setup/create-application). diff --git a/src/fragments/lib/auth/android/getting_started/50_configureBackend.mdx b/src/fragments/lib/auth/android/getting_started/50_configureBackend.mdx new file mode 100644 index 00000000000..0792c004216 --- /dev/null +++ b/src/fragments/lib/auth/android/getting_started/50_configureBackend.mdx @@ -0,0 +1,143 @@ + + + +> Prerequisites: [Install and configure](/lib/project-setup/prereq/q/platform/android/#install-and-configure-the-amplify-cli) the Amplify CLI in addition to the Amplify libraries and [necessary dependencies](/lib/auth/getting-started/q/platform/android/#install-amplify-libraries). + +To start provisioning auth resources in the backend, go to your project directory and **execute the command**: + +```bash +amplify add auth +``` + +Enter the following when prompted: +```console +? 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.` +``` + +> If you have previously enabled an Amplify category that uses Auth behind the scenes (e.g. API category), you can run the `amplify update auth` command to edit your configuration if needed. + +To push your changes to the cloud, **execute the command**: + +```bash +amplify push +``` + +import android5 from "/src/fragments/lib/auth/android/getting_started/12_amplifyConfig.mdx"; + + + + + + + +> Prerequisites: [Install and configure](/lib/project-setup/prereq/q/platform/android/#install-and-configure-the-amplify-cli) the Amplify CLI in addition to the Amplify libraries and [necessary dependencies](/lib/auth/getting-started/q/platform/android/#install-amplify-libraries). + +To import existing Amazon Cognito resources into your Amplify project, **execute the command**: + +```bash +amplify import auth +``` +```console +? What type of auth resource do you want to import? + Cognito User Pool and Identity Pool + Cognito User Pool only +``` + +Once you've selected an option, you'll be able to search for and import an existing Cognito User Pool and Identity Pool (or User Pool only) within your AWS account. The `amplify import auth` command will also do the following: +- Automatically populate your Amplify Library configuration file (`amplifyconfiguration.json`) with your chosen Amazon Cognito resource information +- Provide your designated existing Cognito resource as the authentication & authorization mechanism for all auth-dependent categories (API, Storage and more) +- Enable Lambda functions to access the chosen Cognito resource if you permit it + +> If you have previously enabled an Amplify category that uses Auth behind the scenes (e.g. API category), you can run the `amplify update auth` command to edit your configuration if needed. + +After configuring your Authentication options, update your backend and deploy the service by running the `push` command: + +```bash +amplify push +``` + +Now, the authentication service has been deployed and you can start using it. To view the deployed services in your project at any time, go to Amplify Console by running the following command: + +```bash +amplify console +``` +For more details, see how to [Use an existing Cognito User Pool and Identity Pool](/cli/auth/import). + + + + + +If you are not using the Amplify CLI, existing Authentication resources from AWS (e.g. Amazon Cognito UserPools or Identity Pools) can be used with the Amplify Libraries by [manually creating a configuration file](/lib/project-setup/use-existing-resources/q/platform/android/#add-an-existing-aws-resource-to-an-android-application) (`amplifyconfiguration.json`) and then updating the associated Plugin within it: + +```jsx +{ + "auth": { + "plugins": { + "awsCognitoAuthPlugin": { + "IdentityManager": { + "Default": {} + }, + "CredentialsProvider": { + "CognitoIdentity": { + "Default": { + "PoolId": "[COGNITO IDENTITY POOL ID]", + "Region": "[REGION]" + } + } + }, + "CognitoUserPool": { + "Default": { + "PoolId": "[COGNITO USER POOL ID]", + "AppClientId": "[COGNITO USER POOL APP CLIENT ID]", + "Region": "[REGION]" + } + }, + "Auth": { + "Default": { + "authenticationFlowType": "USER_SRP_AUTH", + "OAuth": { + "WebDomain": "[YOUR COGNITO DOMAIN ]", + "AppClientId": "[COGNITO USER POOL APP CLIENT ID]", + "SignInRedirectURI": "[CUSTOM REDIRECT SCHEME AFTER SIGN IN, e.g. myapp://]", + "SignOutRedirectURI": "[CUSTOM REDIRECT SCHEME AFTER SIGN OUT, e.g. myapp://]", + "Scopes": [ + "phone", + "email", + "openid", + "profile", + "aws.cognito.signin.user.admin" + ] + } + } + } + } + } + } +} +``` + +- **CredentialsProvider**: + - **Cognito Identity**: + - **Default**: + - **PoolID**: ID of the Amazon Cognito Identity Pool (e.g. `us-east-1:123e4567-e89b-12d3-a456-426614174000`) + - **Region**: AWS Region where the resources are provisioned (e.g. `us-east-1`) +- **CognitoUserPool**: + - **Default**: + - **PoolId**: ID of the Amazon Cognito User Pool (e.g. `us-east-1_abcdefghi`) + - **AppClientId**: ID for the client used to authenticate against the user pool + - **Region**: AWS Region where the resources are provisioned (e.g. `us-east-1`) +- **Auth**: + - **Default**: + - **authenticationFlowType**: The authentication flow type, takes values `USER_SRP_AUTH`, `CUSTOM_AUTH`, and `USER_PASSWORD_AUTH`. Default is `USER_SRP_AUTH`. + - **OAuth**: Hosted UI Configuration (only include this if using the Hosted UI flow) + - **Scopes:** Scopes should match the scopes enables in Cognito under "App client settings" + +If you are using a Cognito User Pool without a Cognito Identity Pool, you can omit the **CredentialsProvider** section in the configuration. + + + \ No newline at end of file diff --git a/src/fragments/lib/auth/existing-resources.mdx b/src/fragments/lib/auth/existing-resources.mdx index 2d89b0eb4ec..00a62dca16f 100644 --- a/src/fragments/lib/auth/existing-resources.mdx +++ b/src/fragments/lib/auth/existing-resources.mdx @@ -26,10 +26,10 @@ import flutter0 from "/src/fragments/lib/auth/flutter/existing_resources/10_exis - **Region**: AWS Region where the resources are provisioned (e.g. `us-east-1`) - **Auth**: - **Default**: - - **authenticationFlowType**: The authentication flow type, takes values `USER_SRP_AUTH`, `CUSTOM_AUTH`. Default is `USER_SRP_AUTH`. + - **authenticationFlowType**: The authentication flow type, takes values `USER_SRP_AUTH`, `CUSTOM_AUTH`, and `USER_PASSWORD_AUTH`. Default is `USER_SRP_AUTH`. - **OAuth**: Hosted UI Configuration (only include this if using the Hosted UI flow) - **Scopes:** Scopes should match the scopes enables in Cognito under "App client settings" Note that before you can add an AWS resource to your application, the application must have the Amplify libraries installed. If you need to perform this step, see [Install Amplify Libraries](/lib/project-setup/create-application#n2-install-amplify-libraries). -If you are using a Cognito User Pool, without a Cognito Identity Pool, you can omit the **CredentialsProvider** section in the configuration. +If you are using a Cognito User Pool without a Cognito Identity Pool, you can omit the **CredentialsProvider** section in the configuration. diff --git a/src/fragments/lib/auth/flutter/existing_resources/10_existingResources.mdx b/src/fragments/lib/auth/flutter/existing_resources/10_existingResources.mdx index 382e1c4f8d9..8314a534d1d 100644 --- a/src/fragments/lib/auth/flutter/existing_resources/10_existingResources.mdx +++ b/src/fragments/lib/auth/flutter/existing_resources/10_existingResources.mdx @@ -40,7 +40,7 @@ const amplifyconfig = ''' { "profile", "aws.cognito.signin.user.admin" ] - }, + } } } } diff --git a/src/fragments/lib/auth/flutter/getting_started/70_configureBackend.mdx b/src/fragments/lib/auth/flutter/getting_started/70_configureBackend.mdx new file mode 100644 index 00000000000..6471bb0705e --- /dev/null +++ b/src/fragments/lib/auth/flutter/getting_started/70_configureBackend.mdx @@ -0,0 +1,155 @@ + + + +> Prerequisites: [Install and configure](/lib/project-setup/prereq/q/platform/flutter/#install-and-configure-the-amplify-cli) the Amplify CLI in addition to the Amplify libraries and [necessary dependencies](/lib/auth/getting-started/q/platform/flutter/#install-amplify-libraries). + +To start provisioning auth resources in the backend, go to your project directory and **execute the command**: + +```bash +amplify add auth +``` + +Enter the following when prompted: +```console +? 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.` +``` + +> If you have previously enabled an Amplify category that uses Auth behind the scenes (e.g. API category), you can run the `amplify update auth` command to edit your configuration if needed. + +To push your changes to the cloud, **execute the command**: + +```bash +amplify push +``` + +import ios3 from "/src/fragments/lib/auth/ios/getting_started/12_amplifyConfig.mdx"; + + + +import android4 from "/src/fragments/lib/auth/android/getting_started/12_amplifyConfig.mdx"; + + + +import flutter5 from "/src/fragments/lib/auth/flutter/getting_started/12_amplifyConfig.mdx"; + + + + + + + +> Prerequisites: [Install and configure](/lib/project-setup/prereq/q/platform/flutter/#install-and-configure-the-amplify-cli) the Amplify CLI in addition to the Amplify libraries and [necessary dependencies](/lib/auth/getting-started/q/platform/flutter/#install-amplify-libraries). + +To import existing Amazon Cognito resources into your Amplify project, **execute the command**: + +```bash +amplify import auth +``` +```console +? What type of auth resource do you want to import? + Cognito User Pool and Identity Pool + Cognito User Pool only +``` + +Once you've selected an option, you'll be able to search for and import an existing Cognito User Pool and Identity Pool (or User Pool only) within your AWS account. The `amplify import auth` command will also do the following: +- Automatically populate your Amplify Library configuration file (`amplifyconfiguration.dart`) with your chosen Amazon Cognito resource information +- Provide your designated existing Cognito resource as the authentication & authorization mechanism for all auth-dependent categories (API, Storage and more) +- Enable Lambda functions to access the chosen Cognito resource if you permit it + +> If you have previously enabled an Amplify category that uses Auth behind the scenes (e.g. API category), you can run the `amplify update auth` command to edit your configuration if needed. + +After configuring your Authentication options, update your backend and deploy the service by running the `push` command: + +```bash +amplify push +``` + +Now, the authentication service has been deployed and you can start using it. To view the deployed services in your project at any time, go to Amplify Console by running the following command: + +```bash +amplify console +``` +For more details, see how to [Use an existing Cognito User Pool and Identity Pool](/cli/auth/import). + + + + + +Existing Authentication resources from AWS (e.g. Amazon Cognito UserPools or Identity Pools) can be used with the Amplify Libraries by calling the `Amplify.configure()` method. + +If you are not using the Amplify CLI, a Cognito User Pool and Identity Pool can be used by referencing them in your `amplifyconfiguration.dart` file: + +```dart +const amplifyconfig = ''' { + "UserAgent": "aws-amplify-cli/2.0", + "Version": "1.0", + "auth": { + "plugins": { + "awsCognitoAuthPlugin": { + "IdentityManager": { + "Default": {} + }, + "CredentialsProvider": { + "CognitoIdentity": { + "Default": { + "PoolId": "[COGNITO IDENTITY POOL ID]", + "Region": "[REGION]" + } + } + }, + "CognitoUserPool": { + "Default": { + "PoolId": "[COGNITO USER POOL ID]", + "AppClientId": "[COGNITO USER POOL APP CLIENT ID]", + "Region": "[REGION]" + } + }, + "Auth": { + "Default": { + "authenticationFlowType": "USER_SRP_AUTH", + "OAuth": { + "WebDomain": "[YOUR COGNITO DOMAIN ]", + "AppClientId": "[COGNITO USER POOL APP CLIENT ID]", + "SignInRedirectURI": "[CUSTOM REDIRECT SCHEME AFTER SIGN IN, e.g. myapp://]", + "SignOutRedirectURI": "[CUSTOM REDIRECT SCHEME AFTER SIGN OUT, e.g. myapp://]", + "Scopes": [ + "phone", + "email", + "openid", + "profile", + "aws.cognito.signin.user.admin" + ] + } + } + } + } + } + } +}'''; +``` + +- **CredentialsProvider**: + - **Cognito Identity**: + - **Default**: + - **PoolID**: ID of the Amazon Cognito Identity Pool (e.g. `us-east-1:123e4567-e89b-12d3-a456-426614174000`) + - **Region**: AWS Region where the resources are provisioned (e.g. `us-east-1`) +- **CognitoUserPool**: + - **Default**: + - **PoolId**: ID of the Amazon Cognito User Pool (e.g. `us-east-1_abcdefghi`) + - **AppClientId**: ID for the client used to authenticate against the user pool + - **Region**: AWS Region where the resources are provisioned (e.g. `us-east-1`) +- **Auth**: + - **Default**: + - **authenticationFlowType**: The authentication flow type, takes values `USER_SRP_AUTH`, `CUSTOM_AUTH`, and `USER_PASSWORD_AUTH`. Default is `USER_SRP_AUTH`. + - **OAuth**: Hosted UI Configuration (only include this if using the Hosted UI flow) + - **Scopes:** Scopes should match the scopes enables in Cognito under "App client settings" + +If you are using a Cognito User Pool without a Cognito Identity Pool, you can omit the **CredentialsProvider** section in the configuration. + + + \ No newline at end of file diff --git a/src/fragments/lib/auth/getting_started/js/getting-started-steps-basic-auth.mdx b/src/fragments/lib/auth/getting_started/js/getting-started-steps-basic-auth.mdx index 1df6dbff9fb..210436947ba 100644 --- a/src/fragments/lib/auth/getting_started/js/getting-started-steps-basic-auth.mdx +++ b/src/fragments/lib/auth/getting_started/js/getting-started-steps-basic-auth.mdx @@ -13,7 +13,7 @@ npm install aws-amplify Install the necessary dependencies by running the following command: ```sh -npm install aws-amplify amazon-cognito-identity-js @react-native-community/netinfo +npm install aws-amplify amazon-cognito-identity-js @react-native-community/netinfo @react-native-async-storage/async-storage ``` You will also need to install the pod dependencies for iOS: @@ -27,7 +27,7 @@ npx pod-install Install the necessary dependencies by running the following command: ```sh -npm install aws-amplify @react-native-community/netinfo +npm install aws-amplify amazon-cognito-identity-js @react-native-community/netinfo @react-native-async-storage/async-storage ``` diff --git a/src/fragments/lib/auth/ios/getting_started/50_configureBackend.mdx b/src/fragments/lib/auth/ios/getting_started/50_configureBackend.mdx new file mode 100644 index 00000000000..8a8d515c9fe --- /dev/null +++ b/src/fragments/lib/auth/ios/getting_started/50_configureBackend.mdx @@ -0,0 +1,154 @@ + + + +> Prerequisites: [Install and configure](/lib/project-setup/prereq/q/platform/ios/#install-and-configure-the-amplify-cli) the Amplify CLI in addition to the Amplify libraries and [necessary dependencies](/lib/auth/getting-started/q/platform/ios/#install-amplify-libraries). + +To start provisioning auth resources in the backend, go to your project directory and **execute the command**: + +```bash +amplify add auth +``` + +Enter the following when prompted: +```console +? 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.` +``` + +> If you have previously enabled an Amplify category that uses Auth behind the scenes (e.g. API category), you can run the `amplify update auth` command to edit your configuration if needed. + +To push your changes to the cloud, **execute the command**: + +```bash +amplify push +``` + +import ios3 from "/src/fragments/lib/auth/ios/getting_started/12_amplifyConfig.mdx"; + + + +import android4 from "/src/fragments/lib/auth/android/getting_started/12_amplifyConfig.mdx"; + + + +import flutter5 from "/src/fragments/lib/auth/flutter/getting_started/12_amplifyConfig.mdx"; + + + + + + + +> Prerequisites: [Install and configure](/lib/project-setup/prereq/q/platform/ios/#install-and-configure-the-amplify-cli) the Amplify CLI in addition to the Amplify libraries and [necessary dependencies](/lib/auth/getting-started/q/platform/ios/#install-amplify-libraries). + +To import existing Amazon Cognito resources into your Amplify project, **execute the command**: + +```bash +amplify import auth +``` +```console +? What type of auth resource do you want to import? + Cognito User Pool and Identity Pool + Cognito User Pool only +``` + +Once you've selected an option, you'll be able to search for and import an existing Cognito User Pool and Identity Pool (or User Pool only) within your AWS account. The `amplify import auth` command will also do the following: +- Automatically populate your Amplify Library configuration file (`awsconfiguration.json`) with your chosen Amazon Cognito resource information +- Provide your designated existing Cognito resource as the authentication & authorization mechanism for all auth-dependent categories (API, Storage and more) +- Enable Lambda functions to access the chosen Cognito resource if you permit it + +> If you have previously enabled an Amplify category that uses Auth behind the scenes (e.g. API category), you can run the `amplify update auth` command to edit your configuration if needed. + +After configuring your Authentication options, update your backend and deploy the service by running the `push` command: + +```bash +amplify push +``` + +Upon completion, `amplifyconfiguration.json` should be updated to reference provisioned backend auth resources. + +Now, the authentication service has been deployed and you can start using it. To view the deployed services in your project at any time, go to Amplify Console by running the following command: + +```bash +amplify console +``` +For more details, see how to [Use an existing Cognito User Pool and Identity Pool](/cli/auth/import). + + + + + +If you are not using the Amplify CLI, existing Authentication resources from AWS (e.g. Amazon Cognito UserPools or Identity Pools) can be used with the Amplify Libraries by [manually creating a configuration file](/lib/project-setup/use-existing-resources/q/platform/ios/#1-manually-create-the-amplify-configuration-file-for-your-ios-project) (`amplifyconfiguration.json`) and then updating the associated Plugin within it: + +```jsx +{ + "auth": { + "plugins": { + "awsCognitoAuthPlugin": { + "IdentityManager": { + "Default": {} + }, + "CredentialsProvider": { + "CognitoIdentity": { + "Default": { + "PoolId": "[COGNITO IDENTITY POOL ID]", + "Region": "[REGION]" + } + } + }, + "CognitoUserPool": { + "Default": { + "PoolId": "[COGNITO USER POOL ID]", + "AppClientId": "[COGNITO USER POOL APP CLIENT ID]", + "Region": "[REGION]" + } + }, + "Auth": { + "Default": { + "authenticationFlowType": "USER_SRP_AUTH", + "OAuth": { + "WebDomain": "[YOUR COGNITO DOMAIN ]", + "AppClientId": "[COGNITO USER POOL APP CLIENT ID]", + "SignInRedirectURI": "[CUSTOM REDIRECT SCHEME AFTER SIGN IN, e.g. myapp://]", + "SignOutRedirectURI": "[CUSTOM REDIRECT SCHEME AFTER SIGN OUT, e.g. myapp://]", + "Scopes": [ + "phone", + "email", + "openid", + "profile", + "aws.cognito.signin.user.admin" + ] + } + } + } + } + } + } +} +``` +> For more information on Plugins, see the instructions on [installing Amplify Libraries](/lib/project-setup/create-application/q/platform/ios/#2-install-amplify-libraries). + +- **CredentialsProvider**: + - **Cognito Identity**: + - **Default**: + - **PoolID**: ID of the Amazon Cognito Identity Pool (e.g. `us-east-1:123e4567-e89b-12d3-a456-426614174000`) + - **Region**: AWS Region where the resources are provisioned (e.g. `us-east-1`) +- **CognitoUserPool**: + - **Default**: + - **PoolId**: ID of the Amazon Cognito User Pool (e.g. `us-east-1_abcdefghi`) + - **AppClientId**: ID for the client used to authenticate against the user pool + - **Region**: AWS Region where the resources are provisioned (e.g. `us-east-1`) +- **Auth**: + - **Default**: + - **authenticationFlowType**: The authentication flow type, takes values `USER_SRP_AUTH`, `CUSTOM_AUTH`, and `USER_PASSWORD_AUTH`. Default is `USER_SRP_AUTH`. + - **OAuth**: Hosted UI Configuration (only include this if using the Hosted UI flow) + - **Scopes:** Scopes should match the scopes enables in Cognito under "App client settings" + +If you are using a Cognito User Pool without a Cognito Identity Pool, you can omit the **CredentialsProvider** section in the configuration. + + + \ No newline at end of file diff --git a/src/fragments/lib/auth/js/getting-started-set-up-backend-resources-react-native.mdx b/src/fragments/lib/auth/js/getting-started-set-up-backend-resources-react-native.mdx new file mode 100644 index 00000000000..760e4196a21 --- /dev/null +++ b/src/fragments/lib/auth/js/getting-started-set-up-backend-resources-react-native.mdx @@ -0,0 +1,180 @@ + + + +> Prerequisites: [Install and configure](/lib/project-setup/prereq/q/platform/react-native/#install-and-configure-the-amplify-cli) the Amplify CLI in addition to the Amplify libraries and [necessary dependencies](/lib/auth/getting-started/q/platform/react-native/#install-amplify-libraries). + +To start provisioning auth resources in the backend, go to your project directory and **execute the command**: + +```bash +amplify add auth +``` + +```console +? 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. +``` +> If you have previously enabled an Amplify category that uses Auth behind the scenes (e.g. API category), you can run the `amplify update auth` command to edit your configuration if needed. + +The CLI prompts will help you to customize your auth flow for your app. With the provided options, you can: +- Customize sign-in/registration flow +- Customize email and SMS messages for Multi-Factor Authentication +- Customize attributes for your users, e.g. name, email +- Enable 3rd party social providers, e.g. Facebook, Twitter, Google and Amazon + +If you wish to federate with social providers [you will need to configure them first](/lib/auth/social#social-providers-and-federation). + +After configuring your Authentication options, update your backend and deploy the service by running the `push` command: + +```bash +amplify push +``` + +Now, the authentication service has been deployed and you can start using it. To view the deployed services in your project at any time, go to Amplify Console by running the following command: + +```bash +amplify console +``` + +In your app's entry point (i.e. **App.js**, **index.js**, **_app.js**, or **main.js**), import and load the configuration file: + +```javascript +import { Amplify, Auth } from 'aws-amplify'; +import awsconfig from './aws-exports'; +Amplify.configure(awsconfig); +``` + + + + + +> Prerequisites: [Install and configure](/lib/project-setup/prereq/q/platform/react-native/#install-and-configure-the-amplify-cli) the Amplify CLI in addition to the Amplify libraries and [necessary dependencies](/lib/auth/getting-started/q/platform/react-native/#install-amplify-libraries). + +To import existing Amazon Cognito resources into your Amplify project, **execute the command**: + +```bash +amplify import auth +``` +```console +? What type of auth resource do you want to import? + Cognito User Pool and Identity Pool + Cognito User Pool only +``` + +Once you've selected an option, you'll be able to search for and import an existing Cognito User Pool and Identity Pool (or User Pool only) within your AWS account. The `amplify import auth` command will also do the following: +- Automatically populate your Amplify Library configuration files (aws-exports.js, amplifyconfiguration.json) with your chosen Amazon Cognito resource information +- Provide your designated existing Cognito resource as the authentication & authorization mechanism for all auth-dependent categories (API, Storage and more) +- Enable Lambda functions to access the chosen Cognito resource if you permit it + +> If you have previously enabled an Amplify category that uses Auth behind the scenes (e.g. API category), you can run the `amplify update auth` command to edit your configuration if needed. + +After configuring your Authentication options, update your backend and deploy the service by running the `push` command: + +```bash +amplify push +``` + +Now, the authentication service has been deployed and you can start using it. To view the deployed services in your project at any time, go to Amplify Console by running the following command: + +```bash +amplify console +``` + +In your app's entry point (i.e. **App.js**, **index.js**, **_app.js**, or **main.js**), import and load the configuration file: + +```javascript +import { Amplify, Auth } from 'aws-amplify'; +import awsconfig from './aws-exports'; +Amplify.configure(awsconfig); +``` + + + + + +Existing Authentication resources from AWS (e.g. Amazon Cognito UserPools or Identity Pools) can be used with the Amplify Libraries by calling the `Amplify.configure()` method. + +In your app's entry point (i.e. **App.js**, **index.js**, **_app.js**, or **main.js**), import and load the configuration file: + +```javascript +import { Amplify, Auth } from 'aws-amplify'; + +Amplify.configure({ + Auth: { + + // REQUIRED only for Federated Authentication - Amazon Cognito Identity Pool ID + identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab', + + // REQUIRED - Amazon Cognito Region + region: 'XX-XXXX-X', + + // OPTIONAL - Amazon Cognito Federated Identity Pool Region + // Required only if it's different from Amazon Cognito Region + identityPoolRegion: 'XX-XXXX-X', + + // OPTIONAL - Amazon Cognito User Pool ID + userPoolId: 'XX-XXXX-X_abcd1234', + + // OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string) + userPoolWebClientId: 'a1b2c3d4e5f6g7h8i9j0k1l2m3', + + // OPTIONAL - Enforce user authentication prior to accessing AWS resources or not + mandatorySignIn: false, + + // OPTIONAL - This is used when autoSignIn is enabled for Auth.signUp + // 'code' is used for Auth.confirmSignUp, 'link' is used for email link verification + signUpVerificationMethod: 'code', // 'code' | 'link' + + // OPTIONAL - Configuration for cookie storage + // Note: if the secure flag is set to true, then the cookie transmission requires a secure protocol + cookieStorage: { + // REQUIRED - Cookie domain (only required if cookieStorage is provided) + domain: '.yourdomain.com', + // OPTIONAL - Cookie path + path: '/', + // OPTIONAL - Cookie expiration in days + expires: 365, + // OPTIONAL - See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite + sameSite: "strict" | "lax", + // OPTIONAL - Cookie secure flag + // Either true or false, indicating if the cookie transmission requires a secure protocol (https). + secure: true + }, + + // OPTIONAL - customized storage object + storage: MyStorage, + + // OPTIONAL - Manually set the authentication flow type. Default is 'USER_SRP_AUTH' + authenticationFlowType: 'USER_PASSWORD_AUTH', + + // OPTIONAL - Manually set key value pairs that can be passed to Cognito Lambda Triggers + clientMetadata: { myCustomKey: 'myCustomValue' }, + + // OPTIONAL - Hosted UI configuration + oauth: { + domain: 'your_cognito_domain', + scope: ['phone', 'email', 'profile', 'openid', 'aws.cognito.signin.user.admin'], + redirectSignIn: 'http://localhost:3000/', + redirectSignOut: 'http://localhost:3000/', + responseType: 'code' // or 'token', note that REFRESH token will only be generated when the responseType is code + } + } +}); + +// You can get the current config object +const currentConfig = Auth.configure(); +``` + +If your existing UserPool client has a required attribute that is NOT set to mutable, you may face login issues when using Social sign in. To resolve this, you will need to create a new UserPool client and mark the required attribute as mutable. + + +### OAuth configuration parameters: +These settings can be found in the Cognito User Pools console under **App Integration** section +- `domain`: This can be found in the **Domain name** sub section +- `scope`: Remember to have the scope allowed on the Cognito App client, this can be found on **App client settings** sub section +- `redirectSignIn`: URL must be present on **Callback URL(s)** , check on **App client settings** sub section +- `redirectSignOut`: URL must be present on **Sign out URL(s)**, check on **App client settings** sub section +- `responseType`: Option must be enabled on the App client, look for **Allowed OAuth Flows** on **App client settings** sub section. *Authorization code grant* is for 'code' value and *Implicit grant* is for 'token' value. + + + \ No newline at end of file diff --git a/src/fragments/lib/auth/js/getting-started-steps-basic-auth-react-native.mdx b/src/fragments/lib/auth/js/getting-started-steps-basic-auth-react-native.mdx index 7901120580a..59913dc4051 100644 --- a/src/fragments/lib/auth/js/getting-started-steps-basic-auth-react-native.mdx +++ b/src/fragments/lib/auth/js/getting-started-steps-basic-auth-react-native.mdx @@ -1,5 +1,5 @@ - + Install the necessary dependencies by running the following command: @@ -13,12 +13,12 @@ You will also need to install the pod dependencies for iOS: npx pod-install ``` - + Install the necessary dependencies by running the following command: ```sh -npm install aws-amplify @react-native-community/netinfo @react-native-async-storage/async-storage +npm install aws-amplify amazon-cognito-identity-js @react-native-community/netinfo @react-native-async-storage/async-storage ``` diff --git a/src/fragments/lib/auth/js/getting-started.mdx b/src/fragments/lib/auth/js/getting-started.mdx index 68b6734aa0d..f320b86b9e8 100644 --- a/src/fragments/lib/auth/js/getting-started.mdx +++ b/src/fragments/lib/auth/js/getting-started.mdx @@ -1,38 +1,8 @@ -> Prerequisite: [Install and configure](/cli/start/install) the Amplify CLI - ## Authentication with Amplify Amplify uses [Amazon Cognito](https://aws.amazon.com/cognito/) as the main authentication provider. Amazon Cognito is a robust user directory service that handles user registration, authentication, account recovery & other operations. In this tutorial, you'll learn how to add authentication to your application using Amazon Cognito and username/password login. -## Create authentication service - -To start from scratch, run the following command in your project's root folder: - -> If you want to re-use an existing authentication resource from AWS (e.g. Amazon Cognito UserPool or Identity Pool) refer to [this section](/lib/auth/start#re-use-existing-authentication-resource). - -```bash -amplify add auth -``` - -```console -? 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. -``` - -To deploy the service, run the `push` command: - -```bash -amplify push -``` - -Now, the authentication service has been deployed and you can start using it. To view the deployed services in your project at any time, go to Amplify Console by running the following command: - -```bash -amplify console -``` - -## Configure your application +## Install Amplify Libraries import js0 from '/src/fragments/lib/auth/js/getting-started-steps-basic-auth.mdx'; @@ -42,13 +12,17 @@ import reactnative0 from '/src/fragments/lib/auth/js/getting-started-steps-basic -In your app's entry point (i.e. **App.js**, **index.js**, **_app.js**, or **main.js**), import and load the configuration file: +## Set Up Backend Resources + +To use Authentication with Amplify, you have the option to set up or import existing Amazon Cognito resources via the Amplify CLI or manually configure them in your application. + +import js10 from '/src/fragments/lib/auth/js/getting-started-steps-basic-auth.mdx'; + + + +import reactnative10 from '/src/fragments/lib/auth/js/getting-started-set-up-backend-resources-react-native.mdx'; -```javascript -import { Amplify, Auth } from 'aws-amplify'; -import awsconfig from './aws-exports'; -Amplify.configure(awsconfig); -``` + ## Enable sign-up, sign-in, and sign-out diff --git a/src/fragments/lib/auth/js/getting_started/10_setUpBackendResources.mdx b/src/fragments/lib/auth/js/getting_started/10_setUpBackendResources.mdx new file mode 100644 index 00000000000..5fb12a9fdd7 --- /dev/null +++ b/src/fragments/lib/auth/js/getting_started/10_setUpBackendResources.mdx @@ -0,0 +1,180 @@ + + + +> Prerequisites: [Install and configure](/lib/project-setup/prereq/q/platform/js/) the Amplify CLI in addition to the Amplify libraries and [necessary dependencies](/lib/auth/getting-started/q/platform/js/#install-amplify-libraries). + +To start provisioning auth resources in the backend, go to your project directory and **execute the command**: + +```bash +amplify add auth +``` + +```console +? 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. +``` +> If you have previously enabled an Amplify category that uses Auth behind the scenes (e.g. API category), you can run the `amplify update auth` command to edit your configuration if needed. + +The CLI prompts will help you to customize your auth flow for your app. With the provided options, you can: +- Customize sign-in/registration flow +- Customize email and SMS messages for Multi-Factor Authentication +- Customize attributes for your users, e.g. name, email +- Enable 3rd party social providers, e.g. Facebook, Twitter, Google and Amazon + +If you wish to federate with social providers [you will need to configure them first](/lib/auth/social#social-providers-and-federation). + +After configuring your Authentication options, update your backend and deploy the service by running the `push` command: + +```bash +amplify push +``` + +Now, the authentication service has been deployed and you can start using it. To view the deployed services in your project at any time, go to Amplify Console by running the following command: + +```bash +amplify console +``` + +In your app's entry point (i.e. **App.js**, **index.js**, **_app.js**, or **main.js**), import and load the configuration file: + +```javascript +import { Amplify, Auth } from 'aws-amplify'; +import awsconfig from './aws-exports'; +Amplify.configure(awsconfig); +``` + + + + + +> Prerequisites: [Install and configure](/lib/project-setup/prereq/q/platform/js/) the Amplify CLI in addition to the Amplify libraries and [necessary dependencies](/lib/auth/getting-started/q/platform/js/#install-amplify-libraries). + +To import existing Amazon Cognito resources into your Amplify project, **execute the command**: + +```bash +amplify import auth +``` +```console +? What type of auth resource do you want to import? + Cognito User Pool and Identity Pool + Cognito User Pool only +``` + +Once you've selected an option, you'll be able to search for and import an existing Cognito User Pool and Identity Pool (or User Pool only) within your AWS account. The `amplify import auth` command will also do the following: +- Automatically populate your Amplify Library configuration files (aws-exports.js, amplifyconfiguration.json) with your chosen Amazon Cognito resource information +- Provide your designated existing Cognito resource as the authentication & authorization mechanism for all auth-dependent categories (API, Storage and more) +- Enable Lambda functions to access the chosen Cognito resource if you permit it + +> If you have previously enabled an Amplify category that uses Auth behind the scenes (e.g. API category), you can run the `amplify update auth` command to edit your configuration if needed. + +After configuring your Authentication options, update your backend and deploy the service by running the `push` command: + +```bash +amplify push +``` + +Now, the authentication service has been deployed and you can start using it. To view the deployed services in your project at any time, go to Amplify Console by running the following command: + +```bash +amplify console +``` + +In your app's entry point (i.e. **App.js**, **index.js**, **_app.js**, or **main.js**), import and load the configuration file: + +```javascript +import { Amplify, Auth } from 'aws-amplify'; +import awsconfig from './aws-exports'; +Amplify.configure(awsconfig); +``` + + + + + +Existing Authentication resources from AWS (e.g. Amazon Cognito UserPools or Identity Pools) can be used with the Amplify Libraries by calling the `Amplify.configure()` method. + +In your app's entry point (i.e. **App.js**, **index.js**, **_app.js**, or **main.js**), import and load the configuration file: + +```javascript +import { Amplify, Auth } from 'aws-amplify'; + +Amplify.configure({ + Auth: { + + // REQUIRED only for Federated Authentication - Amazon Cognito Identity Pool ID + identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab', + + // REQUIRED - Amazon Cognito Region + region: 'XX-XXXX-X', + + // OPTIONAL - Amazon Cognito Federated Identity Pool Region + // Required only if it's different from Amazon Cognito Region + identityPoolRegion: 'XX-XXXX-X', + + // OPTIONAL - Amazon Cognito User Pool ID + userPoolId: 'XX-XXXX-X_abcd1234', + + // OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string) + userPoolWebClientId: 'a1b2c3d4e5f6g7h8i9j0k1l2m3', + + // OPTIONAL - Enforce user authentication prior to accessing AWS resources or not + mandatorySignIn: false, + + // OPTIONAL - This is used when autoSignIn is enabled for Auth.signUp + // 'code' is used for Auth.confirmSignUp, 'link' is used for email link verification + signUpVerificationMethod: 'code', // 'code' | 'link' + + // OPTIONAL - Configuration for cookie storage + // Note: if the secure flag is set to true, then the cookie transmission requires a secure protocol + cookieStorage: { + // REQUIRED - Cookie domain (only required if cookieStorage is provided) + domain: '.yourdomain.com', + // OPTIONAL - Cookie path + path: '/', + // OPTIONAL - Cookie expiration in days + expires: 365, + // OPTIONAL - See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite + sameSite: "strict" | "lax", + // OPTIONAL - Cookie secure flag + // Either true or false, indicating if the cookie transmission requires a secure protocol (https). + secure: true + }, + + // OPTIONAL - customized storage object + storage: MyStorage, + + // OPTIONAL - Manually set the authentication flow type. Default is 'USER_SRP_AUTH' + authenticationFlowType: 'USER_PASSWORD_AUTH', + + // OPTIONAL - Manually set key value pairs that can be passed to Cognito Lambda Triggers + clientMetadata: { myCustomKey: 'myCustomValue' }, + + // OPTIONAL - Hosted UI configuration + oauth: { + domain: 'your_cognito_domain', + scope: ['phone', 'email', 'profile', 'openid', 'aws.cognito.signin.user.admin'], + redirectSignIn: 'http://localhost:3000/', + redirectSignOut: 'http://localhost:3000/', + responseType: 'code' // or 'token', note that REFRESH token will only be generated when the responseType is code + } + } +}); + +// You can get the current config object +const currentConfig = Auth.configure(); +``` + +If your existing UserPool client has a required attribute that is NOT set to mutable, you may face login issues when using Social sign in. To resolve this, you will need to create a new UserPool client and mark the required attribute as mutable. + + +### OAuth configuration parameters: +These settings can be found in the Cognito User Pools console under **App Integration** section +- `domain`: This can be found in the **Domain name** sub section +- `scope`: Remember to have the scope allowed on the Cognito App client, this can be found on **App client settings** sub section +- `redirectSignIn`: URL must be present on **Callback URL(s)** , check on **App client settings** sub section +- `redirectSignOut`: URL must be present on **Sign out URL(s)**, check on **App client settings** sub section +- `responseType`: Option must be enabled on the App client, look for **Allowed OAuth Flows** on **App client settings** sub section. *Authorization code grant* is for 'code' value and *Implicit grant* is for 'token' value. + + + \ No newline at end of file diff --git a/src/fragments/lib/auth/js/start.mdx b/src/fragments/lib/auth/js/start.mdx index dbafa4a2f22..a2baa215db9 100644 --- a/src/fragments/lib/auth/js/start.mdx +++ b/src/fragments/lib/auth/js/start.mdx @@ -1,6 +1,6 @@ ## Create new authentication resource -If you have previously enabled an Amplify category that uses Auth behind the scenes, e.g. API category, you may already have an Auth configuration. In such a case, run `amplify auth update` command to edit your configuration. To start from scratch, run the following command in your project's root folder: +> If you have previously enabled an Amplify category that uses Auth behind the scenes (e.g. API category), you can run the `amplify update auth` command to edit your configuration if needed. ```bash amplify add auth diff --git a/src/fragments/lib/auth/native_common/getting_started/common.mdx b/src/fragments/lib/auth/native_common/getting_started/common.mdx index ecad9221ef0..7fe6f4739e5 100644 --- a/src/fragments/lib/auth/native_common/getting_started/common.mdx +++ b/src/fragments/lib/auth/native_common/getting_started/common.mdx @@ -1,11 +1,12 @@ -The Amplify Auth category provides an interface for authenticating a user. Behind the scenes, it provides the necessary authorization to the other Amplify categories. It comes with default, built-in support for [Amazon Cognito](https://aws.amazon.com/cognito) User Pool and Identity Pool. The Amplify CLI helps you to create and configure the auth category with an authentication provider. +The Amplify Auth category provides an interface for authenticating a user. Behind the scenes, it provides the necessary authorization to the other Amplify categories. It comes with default, built-in support for [Amazon Cognito](https://aws.amazon.com/cognito) User Pool and Identity Pool. The Amplify CLI helps you create and configure the auth category with an authentication provider. import flutter0 from "/src/fragments/lib/auth/flutter/getting_started/60_developerPreview.mdx"; ## Goal -To setup and configure your application with Amplify Auth and go through a simple api to check the current auth session + +To setup and configure your application with Amplify Auth and go through a simple api to check the current auth session. ## Prerequisites @@ -21,55 +22,40 @@ import flutter2 from "/src/fragments/lib/auth/flutter/getting_started/10_preReq. -## Configure Auth Category -To start provisioning auth resources in the backend, go to your project directory and **execute the command**: +## Install Amplify Libraries + +import ios6 from "/src/fragments/lib/auth/ios/getting_started/20_installLib.mdx"; -```bash -amplify add auth -``` + -Enter the following when prompted: -```console -? 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.` -``` +import android7 from "/src/fragments/lib/auth/android/getting_started/20_installLib.mdx"; -To push your changes to the cloud, **execute the command**: + -```bash -amplify push -``` +import flutter8 from "/src/fragments/lib/auth/flutter/getting_started/20_installLib.mdx"; -import ios3 from "/src/fragments/lib/auth/ios/getting_started/12_amplifyConfig.mdx"; + - -import android4 from "/src/fragments/lib/auth/android/getting_started/12_amplifyConfig.mdx"; - +## Set Up Backend Resources -import flutter5 from "/src/fragments/lib/auth/flutter/getting_started/12_amplifyConfig.mdx"; +To use Authentication with Amplify, you have the option to set up or import existing Amazon Cognito resources via the Amplify CLI or manually configure them in your application. - +import ios50 from "/src/fragments/lib/auth/ios/getting_started/50_configureBackend.mdx"; -## Install Amplify Libraries + -import ios6 from "/src/fragments/lib/auth/ios/getting_started/20_installLib.mdx"; +import android50 from "/src/fragments/lib/auth/android/getting_started/50_configureBackend.mdx"; - + -import android7 from "/src/fragments/lib/auth/android/getting_started/20_installLib.mdx"; +import flutter70 from "/src/fragments/lib/auth/flutter/getting_started/70_configureBackend.mdx"; - + -import flutter8 from "/src/fragments/lib/auth/flutter/getting_started/20_installLib.mdx"; - ## Initialize Amplify Auth diff --git a/src/fragments/lib/project-setup/android/use-existing-resources/use-existing-resources.mdx b/src/fragments/lib/project-setup/android/use-existing-resources/use-existing-resources.mdx index b26764fc320..2e92d6741e7 100644 --- a/src/fragments/lib/project-setup/android/use-existing-resources/use-existing-resources.mdx +++ b/src/fragments/lib/project-setup/android/use-existing-resources/use-existing-resources.mdx @@ -90,5 +90,5 @@ Select a category from the following list to view an example `amplifyconfigurati * See the [Analytics category](/lib/analytics/existing-resources) to use existing AWS Pinpoint resources. * See the [API (GraphQL) category](/lib/graphqlapi/existing-resources) to use existing AWS AppSync resources. * See the [API (REST) category](/lib/restapi/existing-resources) to use existing Amazon API Gateway and AWS Lambda resources. -* See the [Authentication category](/lib/auth/existing-resources) to use existing Amazon Cognito resources. +* See the [Authentication category](/lib/auth/getting-started/q/platform/android/#prerequisites) to use existing Amazon Cognito resources. * See the [Storage category](/lib/storage/existing-resources) to use existing Amazon S3 resources.