aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.3k stars 240 forks source link

AWS Cognito - Amplify Configuration Manual - Flutter #2291

Open balajiks-dev opened 1 year ago

balajiks-dev commented 1 year ago

Description

Hey Devs, I have to write amplifyconfiguration.dart file manually without doing amplify configure in my Flutter Project. My Flutter Project using AWS Cognito for SignUp and SignIn. I only have AppId, Pool Id and Region. How can i able to achieve it.

Thanks

Categories

Steps to Reproduce

No response

Screenshots

No response

Platforms

Android Device/Emulator API Level

No response

Environment

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.4, on macOS 12.6 21G115 darwin-arm, locale
    en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.71.0)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!

Dependencies

Dart SDK 2.18.2
Flutter SDK 3.3.4
aws_authentication 1.0.0+1

dependencies:
- amplify_auth_cognito 0.6.9 [amplify_auth_cognito_android amplify_auth_cognito_ios amplify_core aws_common collection flutter meta plugin_platform_interface]
- amplify_flutter 0.6.9 [amplify_core amplify_datastore_plugin_interface amplify_flutter_android amplify_flutter_ios aws_common collection flutter meta plugin_platform_interface]
- cupertino_icons 1.0.5
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]

transitive dependencies:
- amplify_auth_cognito_android 0.6.9 [flutter]
- amplify_auth_cognito_ios 0.6.9 [amplify_core flutter]
- amplify_core 0.6.9 [aws_common collection flutter intl json_annotation meta plugin_platform_interface uuid]
- amplify_datastore_plugin_interface 0.6.9 [amplify_core collection flutter meta]
- amplify_flutter_android 0.6.9 [flutter]
- amplify_flutter_ios 0.6.9 [amplify_core flutter]
- async 2.9.0 [collection meta]
- aws_common 0.1.1 [async collection http meta stream_transform uuid]
- characters 1.2.1
- clock 1.1.1
- collection 1.16.0
- crypto 3.0.2 [typed_data]
- http 0.13.5 [async http_parser meta path]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- intl 0.17.0 [clock path]
- json_annotation 4.7.0 [meta]
- material_color_utilities 0.1.5
- meta 1.8.0
- path 1.8.2
- plugin_platform_interface 2.1.3 [meta]
- sky_engine 0.0.99
- source_span 1.9.0 [collection path term_glyph]
- stream_transform 2.0.1
- string_scanner 1.1.1 [source_span]
- term_glyph 1.2.1
- typed_data 1.3.1 [collection]
- uuid 3.0.6 [crypto]
- vector_math 2.1.2

Device

N/A

OS

MacOS

Deployment Method

Amplify CLI

CLI Version

No response

Additional Context

No response

Amplify Config

var json = { "CognitoUserPool": { "Default": {"PoolId": "us-west-1", "AppClientId": "APP ID", "Region": "REGION"} } };

dnys1 commented 1 year ago

Hi @balajiks-dev thank you for the callout around the lack of documentation regarding the amplifyconfiguration file. The amplifyconfiguration file is parsed by the libraries into the AmplifyConfig type exported from package:amplify_flutter. If you'd prefer a typed interface, I would recommend creating a config this way then calling jsonEncode(config) to get the string expected by Amplify.configure.

There are some examples of building AmplifyConfig objects scattered throughout the library. We are also working on adding helper classes to the category configs, like AuthConfig.cognito to try and make it even easier. Although, this work is only happening in our dev-preview (v1.0.0-0) versions of the library.

Hope this helps!

balajiks-dev commented 1 year ago

Hi @dnys1 Thank you for your message. Hope it will be solved in the documentation for better understandable.

Jordan-Nelson commented 1 year ago

I recognize that documentation for this is still missing for this. However, I am marking this as a feature request as we are currently investigating ways that we can improve the experience around this (in addition to docs updates)

JesseRiemens commented 9 months ago

I have another problem with this file, as I cannot get it generated with CI. Should I create a seperate issue for that? I am using this script (Left out personal details)

FLUTTERCONFIG="{\
\"ResDir\":\"lib\",\
\"SourceDir\":\"lib\",\
\"DistributionDir\":\"build\",\
\"BuildCommand\":\"flutter build web\",\
\"StartCommand\":\"flutter run -d chrome\"\
}"
FRONTEND="{\
\"frontend\":\"flutter\",\
\"framework\":\"flutter\",\
\"config\":$FLUTTERCONFIG\
}"
PROVIDERS="{\
\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\
}"

amplify pull \
--frontend $FRONTEND \
--amplify $AMPLIFY \
--providers $PROVIDERS \
--yes

But this does not generate the file for me, even though it is generated when I use the interactive version of the CLI. What am I doing wrong?

Jordan-Nelson commented 6 months ago

FYI - Documentation on existing resources can now be found on the "Existing Resources" tab here: https://docs.amplify.aws/flutter/build-a-backend/auth/set-up-auth/#set-up-backend-resources

balajiks-dev commented 4 months ago

@Jordan-Nelson I think it will be useful now. Thanks for your support!