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 239 forks source link

How to Use auth resources without an Amplify backend? #5053

Open flutterocks opened 1 week ago

flutterocks commented 1 week ago

Description

There is amplify documentation for React on Use auth resources without an Amplify backend, but there is nothing for Flutter.

Is this possible with amplify in flutter?

Categories

Steps to Reproduce

n/a

Screenshots

No response

Platforms

Flutter Version

3.19

Amplify Flutter Version

1.7

Deployment Method

Custom Pipeline

Schema

No response

tyllark commented 1 week ago

Hello @flutterocks thank you for submitting this issue. Flutter can use auth resources without an Amplify backend by modifying amplifyconfiguration.dart in gen 1 or modifying amplify_outputs.json in gen 2.

Please let us know if the linked documentation answers your question!

flutterocks commented 1 week ago

How do I consume the amplify_outputs.json or generate amplifyconfiguration based on it? I am not using Amplify as a backend, just cognito

Jordan-Nelson commented 1 week ago

If you are not using Amplify at all you can still use the defineBackend function with an empty object and then add your own cognito resources following this example: https://docs.amplify.aws/flutter/build-a-backend/auth/use-existing-cognito-resources/#use-auth-resources-with-an-amplify-backend

You can then use amplify to generate the amplifyconfiguration.dart (npx ampx generate outputs --format dart --outputs-version 0) or amplify_outputs.dart (npx ampx generate outputs --format dart). Note that Amplify Flutter does not yet support amplify_outputs.dart, but should soon.

If you do not want to go that route you could write the amplifyconfiguration.dart (and later amplify_outputs.dart) manually.

flutterocks commented 1 week ago

Ensure you are running ampx commands in root of your project (i.e. in the parent of the 'amplify' directory).

Do I need to create a NPM project to run this?

Jordan-Nelson commented 1 week ago

Yes, you would need to create a npm project. I suggest creating an amplify backend app (npm create amplify@latest -y) but you can then remove the auth/data resources which are added by default.

Jordan-Nelson commented 3 days ago

@flutterocks let me know if you have any other questions